Re: [Qemu-devel] [PATCH] CHECKPATCH

2012-09-02 Thread Blue Swirl
On Sat, Sep 1, 2012 at 3:57 PM, Don Slutz d...@cloudswitch.com wrote:
 I took my best guess as to how to handle tabs and long lines in
 checkpatch.pl itself.

Right, it was taken from Linux without much change.


 So I get:
 ...
 total: 0 errors, 7 warnings, 131 lines checked

 I also did not figure out how to run a more complete test of the
 change.  Any pointers as to how would be helpful.

I've used the following snippet to check what happens with the last 100 commits:
for i in '' 1 2 3 4 5 6 7 8 9; do for j in 0 1 2 3 4 5 6 7 8 9; do
echo $i$j; git show HEAD~$i$j /tmp/a; clear;head -20 /tmp/a;
./scripts/checkpatch.pl --root=. /tmp/a; read foo; done; done

Sadly, it also shows how much stuff gets committed without checking,
and on the other hand, the amount of false alarms.



 Don Slutz (1):
   CHECKPATCH: Add warning for single else statement.

  scripts/checkpatch.pl |   72 
  1 files changed, 48 insertions(+), 24 deletions(-)




Re: [Qemu-devel] [PATCH] CHECKPATCH: Add warning for single else statement.

2012-09-02 Thread Blue Swirl
On Sat, Sep 1, 2012 at 3:57 PM, Don Slutz d...@cloudswitch.com wrote:
 Also add more debug options to find this issue.  They were not listed
 in the help because the are not simple to understand the output of.

These should form another patch, now it's not easy to see what was the
fix for 'else'.


 For an example:

 WARNING: braces {} are necessary even for single statement blocks
 +} else
 +return env-regs[R_EAX];

 total: 0 errors, 1 warnings, 41 lines checked

 Signed-off-by: Don Slutz d...@cloudswitch.com
 ---
  scripts/checkpatch.pl |   72 
  1 files changed, 48 insertions(+), 24 deletions(-)

 diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
 index b98dc6c..140a3a6 100755
 --- a/scripts/checkpatch.pl
 +++ b/scripts/checkpatch.pl
 @@ -97,6 +97,9 @@ my $dbg_values = 0;
  my $dbg_possible = 0;
  my $dbg_type = 0;
  my $dbg_attr = 0;
 +my $dbg_adv_dcs = 0;
 +my $dbg_adv_apw = 0;
 +my $dbg_adv_checking = 0;
  for my $key (keys %debug) {
 ## no critic
 eval \${dbg_$key} = '$debug{$key}';;
 @@ -2486,8 +2489,11 @@ sub process {
 if ($line =~ /(^.*)\bif\b/  $line !~ /\#\s*if/) {
 my ($level, $endln, @chunks) =
 ctx_statement_full($linenr, $realcnt, 1);
 -   #print chunks$#chunks linenr$linenr 
 endln$endln level$level\n;
 -   #print APW: $chunks[1][0]$chunks[1][1]\n;
 +if ($dbg_adv_apw) {
 +print APW: chunks$#chunks linenr$linenr 
 endln$endln level$level\n;
 +print APW: $chunks[1][0]$chunks[1][1]\n
 +if $#chunks = 1;
 +}
 if ($#chunks = 0  $level == 0) {
 my $allowed = 0;
 my $seen = 0;
 @@ -2500,7 +2506,8 @@ sub process {
 my ($whitespace) = ($cond =~ 
 /^((?:\s*\n[+-])*\s*)/s);
 my $offset = 
 statement_rawlines($whitespace) - 1;

 -   #print COND$cond 
 whitespace$whitespace offset$offset\n;
 +print COND$cond 
 whitespace$whitespace offset$offset\n
 +if $dbg_adv_apw;

 # We have looked at and allowed this 
 specific line.
 $suppress_ifbraces{$ln + $offset} = 1;
 @@ -2512,18 +2519,22 @@ sub process {

 $seen++ if ($block =~ /^\s*{/);

 -   #print cond$cond block$block 
 allowed$allowed\n;
 +print APW: cond$cond 
 block$block allowed$allowed\n
 +if $dbg_adv_apw;
 if (statement_lines($cond)  1) {
 -   #print APW: ALLOWED: 
 cond$cond\n;
 -   $allowed = 1;
 +print APW: ALLOWED: 
 cond$cond\n
 +if $dbg_adv_apw;
 +$allowed = 1;
 }
 if ($block =~/\b(?:if|for|while)\b/) {
 -   #print APW: ALLOWED: 
 block$block\n;
 -   $allowed = 1;
 +print APW: ALLOWED: 
 block$block\n
 +if $dbg_adv_apw;
 +$allowed = 1;
 }
 if (statement_block_size($block)  1) 
 {
 -   #print APW: ALLOWED: lines 
 block$block\n;
 -   $allowed = 1;
 +print APW: ALLOWED: lines 
 block$block\n
 +if $dbg_adv_apw;
 +$allowed = 1;
 }
 }
 if ($seen != ($#chunks + 1)) {
 @@ -2537,44 +2548,57 @@ sub process {
 $line !~ /\#\s*else/) {
 my $allowed = 0;

 -   # Check the pre-context.
 -   if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
 -   #print APW: ALLOWED: pre$1\n;
 -   $allowed = 1;
 -   }
 +# Check the pre-context.
 +if 

Re: [Qemu-devel] [PATCH] target-i386: Report on error during cpu_x86_register().

2012-09-02 Thread Blue Swirl
On Sat, Sep 1, 2012 at 8:47 PM, Don Slutz d...@cloudswitch.com wrote:
 Send it to stderr before free of the details.

 Signed-off-by: Don Slutz d...@cloudswitch.com
 ---
  target-i386/cpu.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 57c064f..5c0fef1 100644
 --- a/target-i386/cpu.c
 +++ b/target-i386/cpu.c
 @@ -1352,6 +1352,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
  }
  object_property_set_str(OBJECT(cpu), def-model_id, model-id, error);
  if (error_is_set(error)) {
 +fprintf(stderr, %s: %s\n, __FUNCTION__, error_get_pretty(error));

__func__ is preferred by checkpatch.pl and also GCC recommends using it:
http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html

  error_free(error);
  return -1;
  }
 --
 1.7.1





Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Sat, Aug 25, 2012 at 3:43 PM, Blue Swirl blauwir...@gmail.com wrote:
 On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang zhlci...@gmail.com wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.

 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.

 USB option of machine options will be set either by:
   * -usb
   * -machine type=pseries,usb=on

 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
  v7-v8 :
   * Declare usb_enabled() and set_usb_option() in sysemu.h
   * Separate USB enablement on sPAPR platform.

  v8-v9:
   * Fix usb_enable() default value on sPAPR and MAC99

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com

 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
 *boot_device,
  n8x0_dss_setup(s);
  n8x0_cbus_setup(s);
  n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))

 Please add braces.
OK, I will do that.


 I don't like this usb_enabled(false) way very much but I don't have
 anything better to suggest.

Thanks,
It seems that default value is false on most of platforms, only true
for several platforms.

  n8x0_usb_setup(s);

  if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
  pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
   floppy, idebus[0], idebus[1], rtc_state);

 -if (pci_enabled  usb_enabled) {
 +if (pci_enabled  usb_enabled(false)) {
  pci_create_simple(pci_bus, piix3_devfn + 2, piix3-usb-uhci);
  }

 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
  ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
  ide_mem[2] = pmac_ide_init(hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
 pic[0x02]);

 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
  cuda_init(cuda_mem, pic[0x19]);

  adb_kbd_init(adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
 dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
  pci_create_simple(pci_bus, -1, pci-ohci);
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create(keyboard);
 -usbdevice_create(mouse);
 +/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create(keyboard);
 +usbdevice_create(mouse);
 +}
  }

  if (graphic_depth != 15  graphic_depth != 32  graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
 dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
  pci_create_simple(pci_bus, -1, pci-ohci);
  }

 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
 index 7a87616..feeb903 100644
 --- a/hw/ppc_prep.c
 +++ b/hw/ppc_prep.c
 @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
  memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
  #endif

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
  pci_create_simple(pci_bus, -1, pci-ohci);
  }

 diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
 index d5f1420..4787279 100644
 --- a/hw/pxa2xx.c
 +++ b/hw/pxa2xx.c
 @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
  s-ssp[i] = (SSIBus *)qdev_get_child_bus(dev, ssi);
  }

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
  sysbus_create_simple(sysbus-ohci, 0x4c00,
  qdev_get_gpio_in(s-pic, PXA2XX_PIC_USBH1));
  }
 @@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, 
 unsigned int sdram_size)
  s-ssp[i] = (SSIBus 

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl blauwir...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf ag...@suse.de wrote:


 On 26.08.2012, at 10:34, Blue Swirl blauwir...@gmail.com wrote:

 On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf ag...@suse.de wrote:


 On 25.08.2012, at 00:43, Blue Swirl blauwir...@gmail.com wrote:

 On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang zhlci...@gmail.com wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.

 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.

 USB option of machine options will be set either by:
 * -usb
 * -machine type=pseries,usb=on

 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
 v7-v8 :
 * Declare usb_enabled() and set_usb_option() in sysemu.h
 * Separate USB enablement on sPAPR platform.

 v8-v9:
 * Fix usb_enable() default value on sPAPR and MAC99

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com

 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
 char *boot_device,
n8x0_dss_setup(s);
n8x0_cbus_setup(s);
n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))

 Please add braces.

 I don't like this usb_enabled(false) way very much but I don't have
 anything better to suggest.

n8x0_usb_setup(s);

if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
 floppy, idebus[0], idebus[1], rtc_state);

 -if (pci_enabled  usb_enabled) {
 +if (pci_enabled  usb_enabled(false)) {
pci_create_simple(pci_bus, piix3_devfn + 2, piix3-usb-uhci);
}

 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
ide_mem[2] = pmac_ide_init(hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
 pic[0x02]);

 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
cuda_init(cuda_mem, pic[0x19]);

adb_kbd_init(adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
   dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
pci_create_simple(pci_bus, -1, pci-ohci);
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create(keyboard);
 -usbdevice_create(mouse);
 +/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create(keyboard);
 +usbdevice_create(mouse);
 +}
}

if (graphic_depth != 15  graphic_depth != 32  graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
   dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, pci-ohci);
}

 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
 index 7a87616..feeb903 100644
 --- a/hw/ppc_prep.c
 +++ b/hw/ppc_prep.c
 @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, pci-ohci);
}

 diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
 index d5f1420..4787279 100644
 --- a/hw/pxa2xx.c
 +++ b/hw/pxa2xx.c
 @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion 
 *address_space,
s-ssp[i] = (SSIBus *)qdev_get_child_bus(dev, ssi);
}

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
sysbus_create_simple(sysbus-ohci, 0x4c00,
qdev_get_gpio_in(s-pic, PXA2XX_PIC_USBH1));
}
 @@ -2239,7 +2239,7 @@ PXA2xxState 

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Alexander Graf


On 02.09.2012, at 09:50, Li Zhang zhlci...@gmail.com wrote:

 On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl blauwir...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf ag...@suse.de wrote:
 
 
 On 26.08.2012, at 10:34, Blue Swirl blauwir...@gmail.com wrote:
 
 On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf ag...@suse.de wrote:
 
 
 On 25.08.2012, at 00:43, Blue Swirl blauwir...@gmail.com wrote:
 
 On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang zhlci...@gmail.com wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.
 
 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.
 
 USB option of machine options will be set either by:
 * -usb
 * -machine type=pseries,usb=on
 
 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.
 
 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
 v7-v8 :
 * Declare usb_enabled() and set_usb_option() in sysemu.h
 * Separate USB enablement on sPAPR platform.
 
 v8-v9:
 * Fix usb_enable() default value on sPAPR and MAC99
 
 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 
 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
 char *boot_device,
   n8x0_dss_setup(s);
   n8x0_cbus_setup(s);
   n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))
 
 Please add braces.
 
 I don't like this usb_enabled(false) way very much but I don't have
 anything better to suggest.
 
   n8x0_usb_setup(s);
 
   if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
   pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
floppy, idebus[0], idebus[1], rtc_state);
 
 -if (pci_enabled  usb_enabled) {
 +if (pci_enabled  usb_enabled(false)) {
   pci_create_simple(pci_bus, piix3_devfn + 2, piix3-usb-uhci);
   }
 
 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
   ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
   ide_mem[2] = pmac_ide_init(hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
 pic[0x02]);
 
 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
   cuda_init(cuda_mem, pic[0x19]);
 
   adb_kbd_init(adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
  dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
 
 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create(keyboard);
 -usbdevice_create(mouse);
 +/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create(keyboard);
 +usbdevice_create(mouse);
 +}
   }
 
   if (graphic_depth != 15  graphic_depth != 32  graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
  dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
 
 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
   }
 
 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
 index 7a87616..feeb903 100644
 --- a/hw/ppc_prep.c
 +++ b/hw/ppc_prep.c
 @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
   memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif
 
 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
   }
 
 diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
 index d5f1420..4787279 100644
 --- a/hw/pxa2xx.c
 +++ b/hw/pxa2xx.c
 @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion 
 *address_space,
   s-ssp[i] = (SSIBus *)qdev_get_child_bus(dev, ssi);
   }
 
 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   sysbus_create_simple(sysbus-ohci, 0x4c00,
   qdev_get_gpio_in(s-pic, 

Re: [Qemu-devel] Detecting context switch in QEMU

2012-09-02 Thread Xin Tong
On Sat, Sep 1, 2012 at 10:52 PM, Mulyadi Santosa
mulyadi.sant...@gmail.com wrote:
 On Sun, Sep 2, 2012 at 2:33 AM, Xin Tong xerox.time.t...@gmail.com wrote:
 I want to detect context switches in QEMU x86_64-softmmu. one of the
 ideas i have is to track the write to CR3. is this valid on QEMU  (
 i.e. are their any cases in which the assumption could break).


 CMIIW, if context switch happen from a parent process to its NPTL
 based thread, or to kernel thread, then CR3 won't be updated since
 they are using the same address space in Linux kernel, right?

 And that includes no TLB flush AFAIK.

Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ?

Xin


 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com



Re: [Qemu-devel] Detecting context switch in QEMU

2012-09-02 Thread Mulyadi Santosa
Hi..

On Sun, Sep 2, 2012 at 10:52 PM, Xin Tong xerox.time.t...@gmail.com wrote:
 Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ?

from the Linux kernel source:
http://lxr.free-electrons.com/source/kernel/sched/core.c#L3456:

/*
2042  * context_switch - switch to the new MM and the new
2043  * thread's register state.
2044  */
2045 static inline void
2046 context_switch(struct rq *rq, struct task_struct *prev,
2047struct task_struct *next)


i am not so good on arch detail...perhaps you have ideas what
thread's register state is?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



[Qemu-devel] [PATCH 00/21] AREG0 patches, final round

2012-09-02 Thread Blue Swirl
Convert remaining targets to AREG0 free mode.

I decided after s390x to not split the remaining op_helper.c
files to for example fpu_helper.c, int_helper.c etc. It may
still make sense especially for MIPS with 3442 lines in
op_helper.c. This can be done later.

After this series, whole of QEMU can be compiled with Clang.

If there are no problems, this should be applied pretty early
in 1.3 cycle.

Blue Swirl (21):
  target-s390x: fix style
  target-s390x: split FPU ops
  target-s390x: split condition code helpers
  target-s390x: split integer helpers
  target-s390x: split memory access helpers
  target-s390x: rename op_helper.c to misc_helper.c
  target-s390x: avoid AREG0 for FPU helpers
  target-s390x: avoid AREG0 for integer helpers
  target-s390x: avoid AREG0 for condition code helpers
  target-s390x: avoid AREG0 for misc helpers
  target-s390x: switch to AREG0 free mode
  target-s390x: split helper.c
  target-lm32: switch to AREG0 free mode
  target-m68k: switch to AREG0 free mode
  target-unicore32: switch to AREG0 free mode
  target-arm: switch to AREG0 free mode
  target-microblaze: switch to AREG0 free mode
  target-cris: switch to AREG0 free mode
  target-sh4: switch to AREG0 free mode
  target-mips: switch to AREG0 free mode
  Remove unused CONFIG_TCG_PASS_AREG0 and dead code

 Makefile.target |8 -
 configure   |   11 -
 cpu-all.h   |   11 -
 cputlb.c|4 -
 dyngen-exec.h   |   70 -
 exec-all.h  |4 -
 hw/spapr_hcall.c|1 -
 softmmu_defs.h  |   21 -
 softmmu_header.h|   63 +-
 softmmu_template.h  |   72 +-
 target-arm/Makefile.objs|2 -
 target-arm/cpu.h|   10 +-
 target-arm/helper.c |8 +-
 target-arm/helper.h |   60 +-
 target-arm/op_helper.c  |   92 +-
 target-arm/translate.c  |  148 +-
 target-cris/Makefile.objs   |2 -
 target-cris/helper.c|4 +-
 target-cris/helper.h|   34 +-
 target-cris/op_helper.c |   89 +-
 target-cris/translate.c |   50 +-
 target-cris/translate_v10.c |   22 +-
 target-lm32/Makefile.objs   |2 -
 target-lm32/helper.h|   20 +-
 target-lm32/op_helper.c |   29 +-
 target-lm32/translate.c |   22 +-
 target-m68k/Makefile.objs   |2 -
 target-m68k/helpers.h   |2 +-
 target-m68k/op_helper.c |   71 +-
 target-m68k/translate.c |   76 +-
 target-microblaze/Makefile.objs |2 -
 target-microblaze/helper.h  |   48 +-
 target-microblaze/op_helper.c   |  115 +-
 target-microblaze/translate.c   |   56 +-
 target-mips/Makefile.objs   |2 -
 target-mips/cpu.h   |   16 +-
 target-mips/helper.h|  410 +++---
 target-mips/op_helper.c | 1065 ---
 target-mips/translate.c |  754 +-
 target-s390x/Makefile.objs  |5 +-
 target-s390x/cc_helper.c|  550 +++
 target-s390x/cpu.c  |   18 +
 target-s390x/cpu.h  |9 +
 target-s390x/fpu_helper.c   |  843 +++
 target-s390x/helper.c   |  617 
 target-s390x/helper.h   |  250 ++--
 target-s390x/int_helper.c   |  201 +++
 target-s390x/mem_helper.c   | 1203 
 target-s390x/misc_helper.c  | 1000 +
 target-s390x/op_helper.c| 3019 ---
 target-s390x/translate.c|  233 ++--
 target-sh4/Makefile.objs|2 -
 target-sh4/helper.h |   84 +-
 target-sh4/op_helper.c  |  182 ++--
 target-sh4/translate.c  |  114 +-
 target-sparc/Makefile.objs  |2 -
 target-unicore32/Makefile.objs  |2 -
 target-unicore32/helper.h   |   26 +-
 target-unicore32/op_helper.c|   65 +-
 target-unicore32/translate.c|   38 +-
 tcg/arm/tcg-target.c|   31 +-
 tcg/arm/tcg-target.h|1 -
 tcg/hppa/tcg-target.c   |   24 -
 tcg/hppa/tcg-target.h   |1 -
 tcg/i386/tcg-target.c   |   30 -
 tcg/i386/tcg-target.h   |1 -
 tcg/ia64/tcg-target.c   |   34 -
 tcg/ia64/tcg-target.h   |1 -
 tcg/mips/tcg-target.c   |   31 +-
 tcg/mips/tcg-target.h   |1 -
 tcg/ppc/tcg-target.c|   38 -
 tcg/ppc64/tcg-target.c  |   28 -
 tcg/s390/tcg-target.c   |   24 -
 tcg/s390/tcg-target.h   |1 -
 tcg/sparc/tcg-target.c  |   30 -
 tcg/sparc/tcg-target.h  |1 -
 tcg/tci/tcg-target.c|4 -
 tci.c   |   12 -
 user-exec.c |   14 -
 79 files changed, 5994 insertions(+), 6254 deletions(-)
 delete mode 100644 dyngen-exec.h
 create mode 100644 target-s390x/cc_helper.c
 create mode 100644 target-s390x/fpu_helper.c
 delete mode 100644 

[Qemu-devel] [PATCH 12/21] target-s390x: split helper.c

2012-09-02 Thread Blue Swirl
Move CPU init to cpu.c and the rest of helper.c to misc_helper.c.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |2 +-
 target-s390x/cpu.c |   18 ++
 target-s390x/helper.c  |  619 
 target-s390x/misc_helper.c |  570 
 4 files changed, 589 insertions(+), 620 deletions(-)
 delete mode 100644 target-s390x/helper.c

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index e728abf..eadcf6a 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,4 +1,4 @@
-obj-y += translate.o helper.o cpu.o interrupt.o
+obj-y += translate.o cpu.o interrupt.o
 obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 619b202..837feff 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -24,6 +24,24 @@
 #include qemu-common.h
 #include qemu-timer.h
 
+S390CPU *cpu_s390x_init(const char *cpu_model)
+{
+S390CPU *cpu;
+CPUS390XState *env;
+static int inited;
+
+cpu = S390_CPU(object_new(TYPE_S390_CPU));
+env = cpu-env;
+
+if (tcg_enabled()  !inited) {
+inited = 1;
+s390x_translate_init();
+}
+
+env-cpu_model_str = cpu_model;
+qemu_init_vcpu(env);
+return cpu;
+}
 
 /* CPUClass::reset() */
 static void s390_cpu_reset(CPUState *s)
diff --git a/target-s390x/helper.c b/target-s390x/helper.c
deleted file mode 100644
index a5741ec..000
--- a/target-s390x/helper.c
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- *  S/390 helpers
- *
- *  Copyright (c) 2009 Ulrich Hecht
- *  Copyright (c) 2011 Alexander Graf
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see http://www.gnu.org/licenses/.
- */
-
-#include cpu.h
-#include gdbstub.h
-#include qemu-timer.h
-#ifndef CONFIG_USER_ONLY
-#include sysemu.h
-#endif
-
-//#define DEBUG_S390
-//#define DEBUG_S390_PTE
-//#define DEBUG_S390_STDOUT
-
-#ifdef DEBUG_S390
-#ifdef DEBUG_S390_STDOUT
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, fmt, ## __VA_ARGS__); \
- qemu_log(fmt, ##__VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) \
-do { qemu_log(fmt, ## __VA_ARGS__); } while (0)
-#endif
-#else
-#define DPRINTF(fmt, ...) \
-do { } while (0)
-#endif
-
-#ifdef DEBUG_S390_PTE
-#define PTE_DPRINTF DPRINTF
-#else
-#define PTE_DPRINTF(fmt, ...) \
-do { } while (0)
-#endif
-
-#ifndef CONFIG_USER_ONLY
-void s390x_tod_timer(void *opaque)
-{
-S390CPU *cpu = opaque;
-CPUS390XState *env = cpu-env;
-
-env-pending_int |= INTERRUPT_TOD;
-cpu_interrupt(env, CPU_INTERRUPT_HARD);
-}
-
-void s390x_cpu_timer(void *opaque)
-{
-S390CPU *cpu = opaque;
-CPUS390XState *env = cpu-env;
-
-env-pending_int |= INTERRUPT_CPUTIMER;
-cpu_interrupt(env, CPU_INTERRUPT_HARD);
-}
-#endif
-
-S390CPU *cpu_s390x_init(const char *cpu_model)
-{
-S390CPU *cpu;
-CPUS390XState *env;
-static int inited;
-
-cpu = S390_CPU(object_new(TYPE_S390_CPU));
-env = cpu-env;
-
-if (tcg_enabled()  !inited) {
-inited = 1;
-s390x_translate_init();
-}
-
-env-cpu_model_str = cpu_model;
-qemu_init_vcpu(env);
-return cpu;
-}
-
-#if defined(CONFIG_USER_ONLY)
-
-void do_interrupt(CPUS390XState *env)
-{
-env-exception_index = -1;
-}
-
-int cpu_s390x_handle_mmu_fault(CPUS390XState *env, target_ulong address,
-   int rw, int mmu_idx)
-{
-/* fprintf(stderr, %s: address 0x%lx rw %d mmu_idx %d\n,
-   __func__, address, rw, mmu_idx); */
-env-exception_index = EXCP_ADDR;
-/* FIXME: find out how this works on a real machine */
-env-__excp_addr = address;
-return 1;
-}
-
-#else /* !CONFIG_USER_ONLY */
-
-/* Ensure to exit the TB after this call! */
-static void trigger_pgm_exception(CPUS390XState *env, uint32_t code,
-  uint32_t ilc)
-{
-env-exception_index = EXCP_PGM;
-env-int_pgm_code = code;
-env-int_pgm_ilc = ilc;
-}
-
-static int trans_bits(CPUS390XState *env, uint64_t mode)
-{
-int bits = 0;
-
-switch (mode) {
-case PSW_ASC_PRIMARY:
-bits = 1;
-break;
-case PSW_ASC_SECONDARY:
-bits = 2;
-break;
-case PSW_ASC_HOME:
-bits = 3;
-break;
-   

[Qemu-devel] [PATCH 06/21] target-s390x: rename op_helper.c to misc_helper.c

2012-09-02 Thread Blue Swirl
Now op_helper.c contains miscellaneous helpers, rename
it to misc_helper.c.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |6 +-
 target-s390x/cpu.h |2 +-
 target-s390x/misc_helper.c |  431 
 target-s390x/op_helper.c   |  431 
 4 files changed, 435 insertions(+), 435 deletions(-)
 create mode 100644 target-s390x/misc_helper.c
 delete mode 100644 target-s390x/op_helper.c

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index b9b3061..a87d26f 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,10 +1,10 @@
-obj-y += translate.o op_helper.o helper.o cpu.o interrupt.o
-obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o
+obj-y += translate.o helper.o cpu.o interrupt.o
+obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/int_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/fpu_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/mem_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
+$(obj)/misc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 97fde5e..0ccb551 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -1005,7 +1005,7 @@ uint32_t set_cc_f64(float64 v1, float64 v2);
 uint32_t set_cc_nz_f32(float32 v);
 uint32_t set_cc_nz_f64(float64 v);
 
-/* op_helper.c */
+/* misc_helper.c */
 void program_interrupt(CPUS390XState *env, uint32_t code, int ilc);
 
 #endif
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
new file mode 100644
index 000..4869674
--- /dev/null
+++ b/target-s390x/misc_helper.c
@@ -0,0 +1,431 @@
+/*
+ *  S/390 misc helper routines
+ *
+ *  Copyright (c) 2009 Ulrich Hecht
+ *  Copyright (c) 2009 Alexander Graf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see http://www.gnu.org/licenses/.
+ */
+
+#include cpu.h
+#include memory.h
+#include cputlb.h
+#include dyngen-exec.h
+#include host-utils.h
+#include helper.h
+#include string.h
+#include kvm.h
+#include qemu-timer.h
+#ifdef CONFIG_KVM
+#include linux/kvm.h
+#endif
+
+#if !defined(CONFIG_USER_ONLY)
+#include softmmu_exec.h
+#endif
+
+#if !defined(CONFIG_USER_ONLY)
+#include sysemu.h
+#endif
+
+/* #define DEBUG_HELPER */
+#ifdef DEBUG_HELPER
+#define HELPER_LOG(x...) qemu_log(x)
+#else
+#define HELPER_LOG(x...)
+#endif
+
+/* raise an exception */
+void HELPER(exception)(uint32_t excp)
+{
+HELPER_LOG(%s: exception %d\n, __func__, excp);
+env-exception_index = excp;
+cpu_loop_exit(env);
+}
+
+#ifndef CONFIG_USER_ONLY
+void program_interrupt(CPUS390XState *env, uint32_t code, int ilc)
+{
+qemu_log(program interrupt at %# PRIx64 \n, env-psw.addr);
+
+if (kvm_enabled()) {
+#ifdef CONFIG_KVM
+kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+#endif
+} else {
+env-int_pgm_code = code;
+env-int_pgm_ilc = ilc;
+env-exception_index = EXCP_PGM;
+cpu_loop_exit(env);
+}
+}
+
+/*
+ * ret  0 indicates program check, ret = 0, 1, 2, 3 - cc
+ */
+int sclp_service_call(CPUS390XState *env, uint32_t sccb, uint64_t code)
+{
+int r = 0;
+int shift = 0;
+
+#ifdef DEBUG_HELPER
+printf(sclp(0x%x, 0x% PRIx64 )\n, sccb, code);
+#endif
+
+/* basic checks */
+if (!memory_region_is_ram(phys_page_find(sccb  TARGET_PAGE_BITS)-mr)) {
+return -PGM_ADDRESSING;
+}
+if (sccb  ~0x7ff8ul) {
+return -PGM_SPECIFICATION;
+}
+
+switch (code) {
+case SCLP_CMDW_READ_SCP_INFO:
+case SCLP_CMDW_READ_SCP_INFO_FORCED:
+while ((ram_size  (20 + shift))  65535) {
+shift++;
+}
+stw_phys(sccb + SCP_MEM_CODE, ram_size  (20 + shift));
+stb_phys(sccb + SCP_INCREMENT, 1  shift);
+stw_phys(sccb + SCP_RESPONSE_CODE, 0x10);
+
+s390_sclp_extint(sccb  ~3);
+break;
+default:
+#ifdef DEBUG_HELPER
+printf(KVM: invalid sclp call 0x%x / 0x% PRIx64 x\n, sccb, code);
+#endif
+r = 3;
+break;
+}
+
+return r;
+}
+
+/* SCLP service call */
+uint32_t HELPER(servc)(uint32_t r1, uint64_t r2)
+{
+int r;
+
+r = 

[Qemu-devel] [PATCH 19/21] target-sh4: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure|2 +-
 target-sh4/Makefile.objs |2 -
 target-sh4/helper.h  |   84 +++---
 target-sh4/op_helper.c   |  182 ++---
 target-sh4/translate.c   |  114 -
 5 files changed, 195 insertions(+), 189 deletions(-)

diff --git a/configure b/configure
index d760e07..d69e43e 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | arm* | cris | i386 | lm32 | m68k | microblaze* | or32 | s390x | 
sparc* | unicore32 | x86_64 | xtensa* | ppc*)
+  alpha | arm* | cris | i386 | lm32 | m68k | microblaze* | or32 | s390x | sh4* 
| sparc* | unicore32 | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-sh4/Makefile.objs b/target-sh4/Makefile.objs
index 2e0e093..ca20f21 100644
--- a/target-sh4/Makefile.objs
+++ b/target-sh4/Makefile.objs
@@ -1,4 +1,2 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-sh4/helper.h b/target-sh4/helper.h
index 95e3c7c..6e4f108 100644
--- a/target-sh4/helper.h
+++ b/target-sh4/helper.h
@@ -1,54 +1,54 @@
 #include def-helper.h
 
-DEF_HELPER_0(ldtlb, void)
-DEF_HELPER_0(raise_illegal_instruction, void)
-DEF_HELPER_0(raise_slot_illegal_instruction, void)
-DEF_HELPER_0(raise_fpu_disable, void)
-DEF_HELPER_0(raise_slot_fpu_disable, void)
-DEF_HELPER_0(debug, void)
-DEF_HELPER_1(sleep, void, i32)
-DEF_HELPER_1(trapa, void, i32)
+DEF_HELPER_1(ldtlb, void, env)
+DEF_HELPER_1(raise_illegal_instruction, void, env)
+DEF_HELPER_1(raise_slot_illegal_instruction, void, env)
+DEF_HELPER_1(raise_fpu_disable, void, env)
+DEF_HELPER_1(raise_slot_fpu_disable, void, env)
+DEF_HELPER_1(debug, void, env)
+DEF_HELPER_2(sleep, void, env, i32)
+DEF_HELPER_2(trapa, void, env, i32)
 
-DEF_HELPER_2(movcal, void, i32, i32)
-DEF_HELPER_0(discard_movcal_backup, void)
-DEF_HELPER_1(ocbi, void, i32)
+DEF_HELPER_3(movcal, void, env, i32, i32)
+DEF_HELPER_1(discard_movcal_backup, void, env)
+DEF_HELPER_2(ocbi, void, env, i32)
 
-DEF_HELPER_2(addv, i32, i32, i32)
-DEF_HELPER_2(addc, i32, i32, i32)
-DEF_HELPER_2(subv, i32, i32, i32)
-DEF_HELPER_2(subc, i32, i32, i32)
-DEF_HELPER_2(div1, i32, i32, i32)
-DEF_HELPER_2(macl, void, i32, i32)
-DEF_HELPER_2(macw, void, i32, i32)
+DEF_HELPER_3(addv, i32, env, i32, i32)
+DEF_HELPER_3(addc, i32, env, i32, i32)
+DEF_HELPER_3(subv, i32, env, i32, i32)
+DEF_HELPER_3(subc, i32, env, i32, i32)
+DEF_HELPER_3(div1, i32, env, i32, i32)
+DEF_HELPER_3(macl, void, env, i32, i32)
+DEF_HELPER_3(macw, void, env, i32, i32)
 
-DEF_HELPER_1(ld_fpscr, void, i32)
+DEF_HELPER_2(ld_fpscr, void, env, i32)
 
 DEF_HELPER_1(fabs_FT, f32, f32)
 DEF_HELPER_1(fabs_DT, f64, f64)
-DEF_HELPER_2(fadd_FT, f32, f32, f32)
-DEF_HELPER_2(fadd_DT, f64, f64, f64)
-DEF_HELPER_1(fcnvsd_FT_DT, f64, f32)
-DEF_HELPER_1(fcnvds_DT_FT, f32, f64)
+DEF_HELPER_3(fadd_FT, f32, env, f32, f32)
+DEF_HELPER_3(fadd_DT, f64, env, f64, f64)
+DEF_HELPER_2(fcnvsd_FT_DT, f64, env, f32)
+DEF_HELPER_2(fcnvds_DT_FT, f32, env, f64)
 
-DEF_HELPER_2(fcmp_eq_FT, void, f32, f32)
-DEF_HELPER_2(fcmp_eq_DT, void, f64, f64)
-DEF_HELPER_2(fcmp_gt_FT, void, f32, f32)
-DEF_HELPER_2(fcmp_gt_DT, void, f64, f64)
-DEF_HELPER_2(fdiv_FT, f32, f32, f32)
-DEF_HELPER_2(fdiv_DT, f64, f64, f64)
-DEF_HELPER_1(float_FT, f32, i32)
-DEF_HELPER_1(float_DT, f64, i32)
-DEF_HELPER_3(fmac_FT, f32, f32, f32, f32)
-DEF_HELPER_2(fmul_FT, f32, f32, f32)
-DEF_HELPER_2(fmul_DT, f64, f64, f64)
+DEF_HELPER_3(fcmp_eq_FT, void, env, f32, f32)
+DEF_HELPER_3(fcmp_eq_DT, void, env, f64, f64)
+DEF_HELPER_3(fcmp_gt_FT, void, env, f32, f32)
+DEF_HELPER_3(fcmp_gt_DT, void, env, f64, f64)
+DEF_HELPER_3(fdiv_FT, f32, env, f32, f32)
+DEF_HELPER_3(fdiv_DT, f64, env, f64, f64)
+DEF_HELPER_2(float_FT, f32, env, i32)
+DEF_HELPER_2(float_DT, f64, env, i32)
+DEF_HELPER_4(fmac_FT, f32, env, f32, f32, f32)
+DEF_HELPER_3(fmul_FT, f32, env, f32, f32)
+DEF_HELPER_3(fmul_DT, f64, env, f64, f64)
 DEF_HELPER_1(fneg_T, f32, f32)
-DEF_HELPER_2(fsub_FT, f32, f32, f32)
-DEF_HELPER_2(fsub_DT, f64, f64, f64)
-DEF_HELPER_1(fsqrt_FT, f32, f32)
-DEF_HELPER_1(fsqrt_DT, f64, f64)
-DEF_HELPER_1(ftrc_FT, i32, f32)
-DEF_HELPER_1(ftrc_DT, i32, f64)
-DEF_HELPER_2(fipr, void, i32, i32)
-DEF_HELPER_1(ftrv, void, i32)
+DEF_HELPER_3(fsub_FT, f32, env, f32, f32)
+DEF_HELPER_3(fsub_DT, f64, env, f64, f64)
+DEF_HELPER_2(fsqrt_FT, f32, env, f32)
+DEF_HELPER_2(fsqrt_DT, f64, env, f64)
+DEF_HELPER_2(ftrc_FT, i32, env, f32)
+DEF_HELPER_2(ftrc_DT, i32, env, f64)
+DEF_HELPER_3(fipr, void, env, i32, i32)
+DEF_HELPER_2(ftrv, void, env, i32)
 
 #include def-helper.h
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c

[Qemu-devel] [PATCH 03/21] target-s390x: split condition code helpers

2012-09-02 Thread Blue Swirl
Move condition code helpers to cc_helper.c.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |3 +-
 target-s390x/cc_helper.c   |  551 
 target-s390x/cpu.h |3 +
 target-s390x/op_helper.c   |  522 +-
 4 files changed, 557 insertions(+), 522 deletions(-)
 create mode 100644 target-s390x/cc_helper.c

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 23b3bd9..f9437d6 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,7 +1,8 @@
 obj-y += translate.o op_helper.o helper.o cpu.o interrupt.o
-obj-y += fpu_helper.o
+obj-y += fpu_helper.o cc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
 $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/fpu_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
+$(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
new file mode 100644
index 000..2ac1659
--- /dev/null
+++ b/target-s390x/cc_helper.c
@@ -0,0 +1,551 @@
+/*
+ *  S/390 condition code helper routines
+ *
+ *  Copyright (c) 2009 Ulrich Hecht
+ *  Copyright (c) 2009 Alexander Graf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see http://www.gnu.org/licenses/.
+ */
+
+#include cpu.h
+#include dyngen-exec.h
+#include helper.h
+
+/* #define DEBUG_HELPER */
+#ifdef DEBUG_HELPER
+#define HELPER_LOG(x...) qemu_log(x)
+#else
+#define HELPER_LOG(x...)
+#endif
+
+static inline uint32_t cc_calc_ltgt_32(CPUS390XState *env, int32_t src,
+   int32_t dst)
+{
+if (src == dst) {
+return 0;
+} else if (src  dst) {
+return 1;
+} else {
+return 2;
+}
+}
+
+static inline uint32_t cc_calc_ltgt0_32(CPUS390XState *env, int32_t dst)
+{
+return cc_calc_ltgt_32(env, dst, 0);
+}
+
+static inline uint32_t cc_calc_ltgt_64(CPUS390XState *env, int64_t src,
+   int64_t dst)
+{
+if (src == dst) {
+return 0;
+} else if (src  dst) {
+return 1;
+} else {
+return 2;
+}
+}
+
+static inline uint32_t cc_calc_ltgt0_64(CPUS390XState *env, int64_t dst)
+{
+return cc_calc_ltgt_64(env, dst, 0);
+}
+
+static inline uint32_t cc_calc_ltugtu_32(CPUS390XState *env, uint32_t src,
+ uint32_t dst)
+{
+if (src == dst) {
+return 0;
+} else if (src  dst) {
+return 1;
+} else {
+return 2;
+}
+}
+
+static inline uint32_t cc_calc_ltugtu_64(CPUS390XState *env, uint64_t src,
+ uint64_t dst)
+{
+if (src == dst) {
+return 0;
+} else if (src  dst) {
+return 1;
+} else {
+return 2;
+}
+}
+
+static inline uint32_t cc_calc_tm_32(CPUS390XState *env, uint32_t val,
+ uint32_t mask)
+{
+uint16_t r = val  mask;
+
+HELPER_LOG(%s: val 0x%x mask 0x%x\n, __func__, val, mask);
+if (r == 0 || mask == 0) {
+return 0;
+} else if (r == mask) {
+return 3;
+} else {
+return 1;
+}
+}
+
+/* set condition code for test under mask */
+static inline uint32_t cc_calc_tm_64(CPUS390XState *env, uint64_t val,
+ uint32_t mask)
+{
+uint16_t r = val  mask;
+
+HELPER_LOG(%s: val 0x%lx mask 0x%x r 0x%x\n, __func__, val, mask, r);
+if (r == 0 || mask == 0) {
+return 0;
+} else if (r == mask) {
+return 3;
+} else {
+while (!(mask  0x8000)) {
+mask = 1;
+val = 1;
+}
+if (val  0x8000) {
+return 2;
+} else {
+return 1;
+}
+}
+}
+
+static inline uint32_t cc_calc_nz(CPUS390XState *env, uint64_t dst)
+{
+return !!dst;
+}
+
+static inline uint32_t cc_calc_add_64(CPUS390XState *env, int64_t a1,
+  int64_t a2, int64_t ar)
+{
+if ((a1  0  a2  0  ar  0) || (a1  0  a2  0  ar  0)) {
+return 3; /* overflow */
+} else {
+if (ar  0) {
+return 1;
+} else if (ar  0) {
+return 2;
+} else {
+return 0;
+}
+}
+}
+
+static inline uint32_t cc_calc_addu_64(CPUS390XState *env, uint64_t a1,
+   

[Qemu-devel] [PATCH 16/21] target-arm: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure|2 +-
 target-arm/Makefile.objs |2 -
 target-arm/cpu.h |   10 ++-
 target-arm/helper.c  |8 +-
 target-arm/helper.h  |   60 +-
 target-arm/op_helper.c   |   92 +---
 target-arm/translate.c   |  148 +++---
 7 files changed, 158 insertions(+), 164 deletions(-)

diff --git a/configure b/configure
index 4fd3b7f..efb5014 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | x86_64 | 
xtensa* | ppc*)
+  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-arm/Makefile.objs b/target-arm/Makefile.objs
index f447c4f..b6f1a9e 100644
--- a/target-arm/Makefile.objs
+++ b/target-arm/Makefile.objs
@@ -2,5 +2,3 @@ obj-y += arm-semi.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-y += neon_helper.o iwmmxt_helper.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index d7f93d9..7fac94f 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -734,9 +734,10 @@ static inline void cpu_pc_from_tb(CPUARMState *env, 
TranslationBlock *tb)
 }
 
 /* Load an instruction and return it in the standard little-endian order */
-static inline uint32_t arm_ldl_code(uint32_t addr, bool do_swap)
+static inline uint32_t arm_ldl_code(CPUARMState *env, uint32_t addr,
+bool do_swap)
 {
-uint32_t insn = ldl_code(addr);
+uint32_t insn = cpu_ldl_code(env, addr);
 if (do_swap) {
 return bswap32(insn);
 }
@@ -744,9 +745,10 @@ static inline uint32_t arm_ldl_code(uint32_t addr, bool 
do_swap)
 }
 
 /* Ditto, for a halfword (Thumb) instruction */
-static inline uint16_t arm_lduw_code(uint32_t addr, bool do_swap)
+static inline uint16_t arm_lduw_code(CPUARMState *env, uint32_t addr,
+ bool do_swap)
 {
-uint16_t insn = lduw_code(addr);
+uint16_t insn = cpu_lduw_code(env, addr);
 if (do_swap) {
 return bswap16(insn);
 }
diff --git a/target-arm/helper.c b/target-arm/helper.c
index dceaa95..f4d711c 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1756,7 +1756,7 @@ static void do_interrupt_v7m(CPUARMState *env)
 case EXCP_BKPT:
 if (semihosting_enabled) {
 int nr;
-nr = arm_lduw_code(env-regs[15], env-bswap_code)  0xff;
+nr = arm_lduw_code(env, env-regs[15], env-bswap_code)  0xff;
 if (nr == 0xab) {
 env-regs[15] += 2;
 env-regs[0] = do_arm_semihosting(env);
@@ -1828,9 +1828,9 @@ void do_interrupt(CPUARMState *env)
 if (semihosting_enabled) {
 /* Check for semihosting interrupt.  */
 if (env-thumb) {
-mask = arm_lduw_code(env-regs[15] - 2, env-bswap_code)  
0xff;
+mask = arm_lduw_code(env, env-regs[15] - 2, env-bswap_code) 
 0xff;
 } else {
-mask = arm_ldl_code(env-regs[15] - 4, env-bswap_code)
+mask = arm_ldl_code(env, env-regs[15] - 4, env-bswap_code)
  0xff;
 }
 /* Only intercept calls from privileged modes, to provide some
@@ -1851,7 +1851,7 @@ void do_interrupt(CPUARMState *env)
 case EXCP_BKPT:
 /* See if this is a semihosting syscall.  */
 if (env-thumb  semihosting_enabled) {
-mask = arm_lduw_code(env-regs[15], env-bswap_code)  0xff;
+mask = arm_lduw_code(env, env-regs[15], env-bswap_code)  0xff;
 if (mask == 0xab
(env-uncached_cpsr  CPSR_M) != ARM_CPU_MODE_USR) {
 env-regs[15] += 2;
diff --git a/target-arm/helper.h b/target-arm/helper.h
index 21e9cfe..afdb2b5 100644
--- a/target-arm/helper.h
+++ b/target-arm/helper.h
@@ -4,12 +4,12 @@ DEF_HELPER_1(clz, i32, i32)
 DEF_HELPER_1(sxtb16, i32, i32)
 DEF_HELPER_1(uxtb16, i32, i32)
 
-DEF_HELPER_2(add_setq, i32, i32, i32)
-DEF_HELPER_2(add_saturate, i32, i32, i32)
-DEF_HELPER_2(sub_saturate, i32, i32, i32)
-DEF_HELPER_2(add_usaturate, i32, i32, i32)
-DEF_HELPER_2(sub_usaturate, i32, i32, i32)
-DEF_HELPER_1(double_saturate, i32, s32)
+DEF_HELPER_3(add_setq, i32, env, i32, i32)
+DEF_HELPER_3(add_saturate, i32, env, i32, i32)
+DEF_HELPER_3(sub_saturate, i32, env, i32, i32)
+DEF_HELPER_3(add_usaturate, i32, env, i32, i32)
+DEF_HELPER_3(sub_usaturate, i32, env, i32, i32)
+DEF_HELPER_2(double_saturate, i32, env, s32)
 DEF_HELPER_2(sdiv, s32, s32, s32)
 DEF_HELPER_2(udiv, i32, i32, i32)
 

[Qemu-devel] [PATCH 0/2 v3] Fix static linking for cURL and SDL

2012-09-02 Thread Yann E. MORIN
Hello All!

Currently, configure checks for cURL and SDL with either pkg-config (the
default), or with {curl,sdl}-config (as a fallback).

But pkg-config and {curl,sdl}-config do not have the same set of options:
  - to check for shared libs, both use the option: --libs
  - to check for static libs:
- pkg-config uses  : --static --libs
- {curl,sdl}-config use: --static-libs

To add to the complexity, pkg-config is called through the querry_pkg_config
wrapper, that already passes --static when static linking is required, but
there is no such wrapper for {curl,sdl}-config, so we miss the occasion to
pass --static-libs.

To fix this:
  - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
xxx-config scripts (eg. curl-config, but later sdl-config too).
Default it to '--libs', which is for shared linking.
  - properly use either --libs for pkg-config (--static is already taken
care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for
{curl,sdl}-config.


Changes since v2:
  - remove trailing reference to cURL in the SDL patch (Stefan Hajnoczi)
  - sent to qemu-devel and cc qemu-trivial (Peter Maydell, Stefan)
  - fix type in the name of the new variable

Changes since v1:
  - drop the spice fix, it is not needed (bad env locally)
  - drop the added --static to calls to pkg-config, as it's already in the
wrapper (Stefan Hajnoczi)

Regards,
Yann E. MORIN.



[Qemu-devel] [PATCH 2/2] configure: fix detection for SDL libs when static linking

2012-09-02 Thread Yann E. MORIN
Currently, configure checks for SDL libs either with pkg-config (the
default), or with sdl-config (as a fallback).

But sdl-config does not have the same set of options as pkg-config:
  - to check for shared libs, both use the option: --libs
  - to check for static libs:
- pkg-config uses: --static --libs
- sdl-config uses: --static-libs

Fix that by using the previously introduced $QEMU_XXX_CONFIG_LIBS_FLAGS
variable, the way it was done previously for cURL.

Also, simplify the code-path for checking for SDL libs with a single,
non-conditional call to $sdlconfig, which is either pkg-config or
sdl-config, as checked just above.

Signed-off-by: Yann E. MORIN yann.morin.1...@free.fr
Reviewed-by: Stefan Hajnoczi stefa...@gmail.com
---
 configure |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 67c9238..c5888fa 100755
--- a/configure
+++ b/configure
@@ -1646,9 +1646,11 @@ fi
 
 if $pkg_config sdl --modversion /dev/null 21; then
   sdlconfig=$pkg_config sdl
+  sdlconfiglibs=--libs
   _sdlversion=`$sdlconfig --modversion 2/dev/null | sed 's/[^0-9]//g'`
 elif has ${sdl_config}; then
   sdlconfig=$sdl_config
+  sdlconfiglibs=$QEMU_XXX_CONFIG_LIBS_FLAGS
   _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
 else
   if test $sdl = yes ; then
@@ -1668,11 +1670,7 @@ if test $sdl != no ; then
 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
 EOF
   sdl_cflags=`$sdlconfig --cflags 2 /dev/null`
-  if test $static = yes ; then
-sdl_libs=`$sdlconfig --static-libs 2/dev/null`
-  else
-sdl_libs=`$sdlconfig --libs 2 /dev/null`
-  fi
+  sdl_libs=`$sdlconfig $sdlconfiglibs 2 /dev/null`
   if compile_prog $sdl_cflags $sdl_libs ; then
 if test $_sdlversion -lt 121 ; then
   sdl_too_old=yes
-- 
1.7.2.5




[Qemu-devel] [PATCH 1/2] configure: fix detection for cURL libs when static linking

2012-09-02 Thread Yann E. MORIN
Currently, to check for cURL, configure uses either pkg-config (the default),
or curl-config (as a fallback).

But curl-config and pkg-config do not have the same set of options:
  - to check for shared libs, both use the option: --libs
  - to check for static libs:
- pkg-config uses: --static --libs
- curl-config uses: --static-libs

To add to the complexity, pkg-config is called through the querry_pkg_config
wrapper, that already passes --static when static linking is required, but
there is no such wrapper for curl-config, so we miss the occasion to pass
--static-libs

To fix this:
  - introduce a new variable QEMU_XXX_CONFIG_LIBS_FLAGS that mirrors the
behavior of QEMU_PKG_CONFIG_FLAGS; this variable can be used by all
xxx-config scripts (eg. curl-config, but later sdl-config too).
Default it to '--libs', which is for shared linking;
  - properly use either --libs for pkg-config (--static is already taken
care of in the wrapper), or $QEMU_XXX_CONFIG_LIBS_FLAGS for curl-config.

Signed-off-by: Yann E. MORIN yann.morin.1...@free.fr
Reviewed-by: Stefan Hajnoczi stefa...@gmail.com
---
 configure |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index d97fd81..67c9238 100755
--- a/configure
+++ b/configure
@@ -126,7 +126,7 @@ audio_win_int=
 cc_i386=i386-pc-linux-gnu-gcc
 libs_qga=
 debug_info=yes
-
+QEMU_XXX_CONFIG_LIBS_FLAGS=--libs
 target_list=
 
 # Default value for a variable defining feature foo.
@@ -626,6 +626,7 @@ for opt do
 static=yes
 LDFLAGS=-static $LDFLAGS
 QEMU_PKG_CONFIG_FLAGS=--static $QEMU_PKG_CONFIG_FLAGS
+QEMU_XXX_CONFIG_LIBS_FLAGS=--static-libs
   ;;
   --mandir=*) mandir=$optarg
   ;;
@@ -2077,8 +2078,10 @@ fi
 
 if $pkg_config libcurl --modversion /dev/null 21; then
   curlconfig=$pkg_config libcurl
+  curlconfiglibs=--libs
 else
   curlconfig=curl-config
+  curlconfiglibs=$QEMU_XXX_CONFIG_LIBS_FLAGS
 fi
 
 if test $curl != no ; then
@@ -2087,7 +2090,7 @@ if test $curl != no ; then
 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
 EOF
   curl_cflags=`$curlconfig --cflags 2/dev/null`
-  curl_libs=`$curlconfig --libs 2/dev/null`
+  curl_libs=`$curlconfig $curlconfiglibs 2/dev/null`
   if compile_prog $curl_cflags $curl_libs ; then
 curl=yes
 libs_tools=$curl_libs $libs_tools
-- 
1.7.2.5




[Qemu-devel] [PATCH 17/21] target-microblaze: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure   |2 +-
 target-microblaze/Makefile.objs |2 -
 target-microblaze/helper.h  |   48 
 target-microblaze/op_helper.c   |  115 ++-
 target-microblaze/translate.c   |   56 +++-
 5 files changed, 108 insertions(+), 115 deletions(-)

diff --git a/configure b/configure
index efb5014..e464d2f 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
x86_64 | xtensa* | ppc*)
+  alpha | arm* | i386 | lm32 | m68k | microblaze* | or32 | s390x | sparc* | 
unicore32 | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-microblaze/Makefile.objs b/target-microblaze/Makefile.objs
index 4b09e8c..afb87bc 100644
--- a/target-microblaze/Makefile.objs
+++ b/target-microblaze/Makefile.objs
@@ -1,4 +1,2 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h
index 9dcfb0f..a1a732c 100644
--- a/target-microblaze/helper.h
+++ b/target-microblaze/helper.h
@@ -1,39 +1,39 @@
 #include def-helper.h
 
-DEF_HELPER_1(raise_exception, void, i32)
-DEF_HELPER_0(debug, void)
+DEF_HELPER_2(raise_exception, void, env, i32)
+DEF_HELPER_1(debug, void, env)
 DEF_HELPER_FLAGS_3(carry, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32, i32)
 DEF_HELPER_2(cmp, i32, i32, i32)
 DEF_HELPER_2(cmpu, i32, i32, i32)
 DEF_HELPER_FLAGS_1(clz, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32)
 
-DEF_HELPER_2(divs, i32, i32, i32)
-DEF_HELPER_2(divu, i32, i32, i32)
-
-DEF_HELPER_2(fadd, i32, i32, i32)
-DEF_HELPER_2(frsub, i32, i32, i32)
-DEF_HELPER_2(fmul, i32, i32, i32)
-DEF_HELPER_2(fdiv, i32, i32, i32)
-DEF_HELPER_1(flt, i32, i32)
-DEF_HELPER_1(fint, i32, i32)
-DEF_HELPER_1(fsqrt, i32, i32)
-
-DEF_HELPER_2(fcmp_un, i32, i32, i32)
-DEF_HELPER_2(fcmp_lt, i32, i32, i32)
-DEF_HELPER_2(fcmp_eq, i32, i32, i32)
-DEF_HELPER_2(fcmp_le, i32, i32, i32)
-DEF_HELPER_2(fcmp_gt, i32, i32, i32)
-DEF_HELPER_2(fcmp_ne, i32, i32, i32)
-DEF_HELPER_2(fcmp_ge, i32, i32, i32)
+DEF_HELPER_3(divs, i32, env, i32, i32)
+DEF_HELPER_3(divu, i32, env, i32, i32)
+
+DEF_HELPER_3(fadd, i32, env, i32, i32)
+DEF_HELPER_3(frsub, i32, env, i32, i32)
+DEF_HELPER_3(fmul, i32, env, i32, i32)
+DEF_HELPER_3(fdiv, i32, env, i32, i32)
+DEF_HELPER_2(flt, i32, env, i32)
+DEF_HELPER_2(fint, i32, env, i32)
+DEF_HELPER_2(fsqrt, i32, env, i32)
+
+DEF_HELPER_3(fcmp_un, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_lt, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_eq, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_le, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_gt, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_ne, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_ge, i32, env, i32, i32)
 
 DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32)
 #if !defined(CONFIG_USER_ONLY)
-DEF_HELPER_1(mmu_read, i32, i32)
-DEF_HELPER_2(mmu_write, void, i32, i32)
+DEF_HELPER_2(mmu_read, i32, env, i32)
+DEF_HELPER_3(mmu_write, void, env, i32, i32)
 #endif
 
-DEF_HELPER_4(memalign, void, i32, i32, i32, i32)
-DEF_HELPER_1(stackprot, void, i32)
+DEF_HELPER_5(memalign, void, env, i32, i32, i32, i32)
+DEF_HELPER_2(stackprot, void, env, i32)
 
 DEF_HELPER_2(get, i32, i32, i32)
 DEF_HELPER_3(put, void, i32, i32, i32)
diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
index 3b1f072..c9789f4 100644
--- a/target-microblaze/op_helper.c
+++ b/target-microblaze/op_helper.c
@@ -20,7 +20,6 @@
 
 #include assert.h
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 #include host-utils.h
 
@@ -42,17 +41,12 @@
 /* Try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
-/* XXX: fix it to restore all registers */
-void tlb_fill(CPUMBState *env1, target_ulong addr, int is_write, int mmu_idx,
+void tlb_fill(CPUMBState *env, target_ulong addr, int is_write, int mmu_idx,
   uintptr_t retaddr)
 {
 TranslationBlock *tb;
-CPUMBState *saved_env;
 int ret;
 
-saved_env = env;
-env = env1;
-
 ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx);
 if (unlikely(ret)) {
 if (retaddr) {
@@ -66,7 +60,6 @@ void tlb_fill(CPUMBState *env1, target_ulong addr, int 
is_write, int mmu_idx,
 }
 cpu_loop_exit(env);
 }
-env = saved_env;
 }
 #endif
 
@@ -105,13 +98,13 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)
 return 0xdead | id;
 }
 
-void helper_raise_exception(uint32_t index)
+void helper_raise_exception(CPUMBState *env, 

[Qemu-devel] [PATCH 10/21] target-s390x: avoid AREG0 for misc helpers

2012-09-02 Thread Blue Swirl
Make misc helpers take a parameter for CPUState instead
of relying on global env.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |1 -
 target-s390x/helper.h  |   26 ++--
 target-s390x/mem_helper.c  |2 +-
 target-s390x/misc_helper.c |   55 +++
 target-s390x/translate.c   |   32 
 5 files changed, 59 insertions(+), 57 deletions(-)

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 736cf33..156d946 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -4,4 +4,3 @@ obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
 $(obj)/mem_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
-$(obj)/misc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/helper.h b/target-s390x/helper.h
index 876b88e..f4e0b37 100644
--- a/target-s390x/helper.h
+++ b/target-s390x/helper.h
@@ -1,6 +1,6 @@
 #include def-helper.h
 
-DEF_HELPER_1(exception, void, i32)
+DEF_HELPER_2(exception, void, env, i32)
 DEF_HELPER_3(nc, i32, i32, i64, i64)
 DEF_HELPER_3(oc, i32, i32, i64, i64)
 DEF_HELPER_3(xc, i32, i32, i64, i64)
@@ -113,20 +113,20 @@ DEF_HELPER_FLAGS_1(cvd, TCG_CALL_PURE|TCG_CALL_CONST, 
i64, s32)
 DEF_HELPER_3(unpk, void, i32, i64, i64)
 DEF_HELPER_3(tr, void, i32, i64, i64)
 
-DEF_HELPER_2(servc, i32, i32, i64)
-DEF_HELPER_3(diag, i64, i32, i64, i64)
+DEF_HELPER_3(servc, i32, env, i32, i64)
+DEF_HELPER_4(diag, i64, env, i32, i64, i64)
 DEF_HELPER_3(load_psw, void, env, i64, i64)
 DEF_HELPER_1(program_interrupt, void, i32)
-DEF_HELPER_FLAGS_1(stidp, TCG_CALL_CONST, void, i64)
-DEF_HELPER_FLAGS_1(spx, TCG_CALL_CONST, void, i64)
+DEF_HELPER_FLAGS_2(stidp, TCG_CALL_CONST, void, env, i64)
+DEF_HELPER_FLAGS_2(spx, TCG_CALL_CONST, void, env, i64)
 DEF_HELPER_FLAGS_1(sck, TCG_CALL_CONST, i32, i64)
-DEF_HELPER_1(stck, i32, i64)
-DEF_HELPER_1(stcke, i32, i64)
-DEF_HELPER_FLAGS_1(sckc, TCG_CALL_CONST, void, i64)
-DEF_HELPER_FLAGS_1(stckc, TCG_CALL_CONST, void, i64)
-DEF_HELPER_FLAGS_1(spt, TCG_CALL_CONST, void, i64)
-DEF_HELPER_FLAGS_1(stpt, TCG_CALL_CONST, void, i64)
-DEF_HELPER_3(stsi, i32, i64, i32, i32)
+DEF_HELPER_2(stck, i32, env, i64)
+DEF_HELPER_2(stcke, i32, env, i64)
+DEF_HELPER_FLAGS_2(sckc, TCG_CALL_CONST, void, env, i64)
+DEF_HELPER_FLAGS_2(stckc, TCG_CALL_CONST, void, env, i64)
+DEF_HELPER_FLAGS_2(spt, TCG_CALL_CONST, void, env, i64)
+DEF_HELPER_FLAGS_2(stpt, TCG_CALL_CONST, void, env, i64)
+DEF_HELPER_4(stsi, i32, env, i64, i32, i32)
 DEF_HELPER_3(lctl, void, i32, i64, i32)
 DEF_HELPER_3(lctlg, void, i32, i64, i32)
 DEF_HELPER_3(stctl, void, i32, i64, i32)
@@ -138,7 +138,7 @@ DEF_HELPER_FLAGS_2(rrbe, TCG_CALL_CONST, i32, i32, i64)
 DEF_HELPER_2(csp, i32, i32, i32)
 DEF_HELPER_3(mvcs, i32, i64, i64, i64)
 DEF_HELPER_3(mvcp, i32, i64, i64, i64)
-DEF_HELPER_3(sigp, i32, i64, i32, i64)
+DEF_HELPER_4(sigp, i32, env, i64, i32, i64)
 DEF_HELPER_2(sacf, void, env, i64)
 DEF_HELPER_FLAGS_2(ipte, TCG_CALL_CONST, void, i64, i64)
 DEF_HELPER_FLAGS_0(ptlb, TCG_CALL_CONST, void)
diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c
index 3f8b3ba..52f2602 100644
--- a/target-s390x/mem_helper.c
+++ b/target-s390x/mem_helper.c
@@ -595,7 +595,7 @@ uint32_t HELPER(ex)(uint32_t cc, uint64_t v1, uint64_t 
addr, uint64_t ret)
 env-psw.addr = ret - 4;
 env-int_svc_code = (insn | v1)  0xff;
 env-int_svc_ilc = 4;
-helper_exception(EXCP_SVC);
+helper_exception(env, EXCP_SVC);
 } else if ((insn  0xff00) == 0xbf00) {
 uint32_t insn2, r1, r3, b2, d2;
 
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 4869674..0ba737a 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -21,7 +21,6 @@
 #include cpu.h
 #include memory.h
 #include cputlb.h
-#include dyngen-exec.h
 #include host-utils.h
 #include helper.h
 #include string.h
@@ -31,7 +30,8 @@
 #include linux/kvm.h
 #endif
 
-#if !defined(CONFIG_USER_ONLY)
+/* temporarily disabled due to wrapper use */
+#if 0  !defined(CONFIG_USER_ONLY)
 #include softmmu_exec.h
 #endif
 
@@ -47,7 +47,7 @@
 #endif
 
 /* raise an exception */
-void HELPER(exception)(uint32_t excp)
+void HELPER(exception)(CPUS390XState *env, uint32_t excp)
 {
 HELPER_LOG(%s: exception %d\n, __func__, excp);
 env-exception_index = excp;
@@ -115,7 +115,7 @@ int sclp_service_call(CPUS390XState *env, uint32_t sccb, 
uint64_t code)
 }
 
 /* SCLP service call */
-uint32_t HELPER(servc)(uint32_t r1, uint64_t r2)
+uint32_t HELPER(servc)(CPUS390XState *env, uint32_t r1, uint64_t r2)
 {
 int r;
 
@@ -128,7 +128,8 @@ uint32_t HELPER(servc)(uint32_t r1, uint64_t r2)
 }
 
 /* DIAG */
-uint64_t HELPER(diag)(uint32_t num, uint64_t mem, uint64_t code)
+uint64_t HELPER(diag)(CPUS390XState *env, uint32_t num, uint64_t mem,
+  uint64_t code)
 {
 uint64_t r;
 
@@ -158,17 +159,17 @@ uint64_t HELPER(diag)(uint32_t num, uint64_t mem, 

[Qemu-devel] [PATCH 02/21] target-s390x: split FPU ops

2012-09-02 Thread Blue Swirl
Move floating point instructions to fpu_helper.c.

While exporting some condition code helpers,
avoid duplicate identifier conflict with translate.c.

Remove unused set_cc_nz_f64() in translate.c.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |2 +
 target-s390x/cpu.h |6 +
 target-s390x/fpu_helper.c  |  836 
 target-s390x/op_helper.c   |  802 --
 target-s390x/translate.c   |   11 +-
 5 files changed, 847 insertions(+), 810 deletions(-)
 create mode 100644 target-s390x/fpu_helper.c

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 80be3bb..23b3bd9 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,5 +1,7 @@
 obj-y += translate.o op_helper.o helper.o cpu.o interrupt.o
+obj-y += fpu_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
 $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
+$(obj)/fpu_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 18ac6e3..b4620c5 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -999,4 +999,10 @@ static inline void cpu_pc_from_tb(CPUS390XState *env, 
TranslationBlock* tb)
 env-psw.addr = tb-pc;
 }
 
+/* fpu_helper.c */
+uint32_t set_cc_f32(float32 v1, float32 v2);
+uint32_t set_cc_f64(float64 v1, float64 v2);
+uint32_t set_cc_nz_f32(float32 v);
+uint32_t set_cc_nz_f64(float64 v);
+
 #endif
diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c
new file mode 100644
index 000..1389052
--- /dev/null
+++ b/target-s390x/fpu_helper.c
@@ -0,0 +1,836 @@
+/*
+ *  S/390 FPU helper routines
+ *
+ *  Copyright (c) 2009 Ulrich Hecht
+ *  Copyright (c) 2009 Alexander Graf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see http://www.gnu.org/licenses/.
+ */
+
+#include cpu.h
+#include dyngen-exec.h
+#include helper.h
+
+#if !defined(CONFIG_USER_ONLY)
+#include softmmu_exec.h
+#endif
+
+/* #define DEBUG_HELPER */
+#ifdef DEBUG_HELPER
+#define HELPER_LOG(x...) qemu_log(x)
+#else
+#define HELPER_LOG(x...)
+#endif
+
+static inline int float_comp_to_cc(int float_compare)
+{
+switch (float_compare) {
+case float_relation_equal:
+return 0;
+case float_relation_less:
+return 1;
+case float_relation_greater:
+return 2;
+case float_relation_unordered:
+return 3;
+default:
+cpu_abort(env, unknown return value for float compare\n);
+}
+}
+
+/* condition codes for binary FP ops */
+uint32_t set_cc_f32(float32 v1, float32 v2)
+{
+return float_comp_to_cc(float32_compare_quiet(v1, v2, env-fpu_status));
+}
+
+uint32_t set_cc_f64(float64 v1, float64 v2)
+{
+return float_comp_to_cc(float64_compare_quiet(v1, v2, env-fpu_status));
+}
+
+/* condition codes for unary FP ops */
+uint32_t set_cc_nz_f32(float32 v)
+{
+if (float32_is_any_nan(v)) {
+return 3;
+} else if (float32_is_zero(v)) {
+return 0;
+} else if (float32_is_neg(v)) {
+return 1;
+} else {
+return 2;
+}
+}
+
+uint32_t set_cc_nz_f64(float64 v)
+{
+if (float64_is_any_nan(v)) {
+return 3;
+} else if (float64_is_zero(v)) {
+return 0;
+} else if (float64_is_neg(v)) {
+return 1;
+} else {
+return 2;
+}
+}
+
+static uint32_t set_cc_nz_f128(float128 v)
+{
+if (float128_is_any_nan(v)) {
+return 3;
+} else if (float128_is_zero(v)) {
+return 0;
+} else if (float128_is_neg(v)) {
+return 1;
+} else {
+return 2;
+}
+}
+
+/* convert 32-bit int to 64-bit float */
+void HELPER(cdfbr)(uint32_t f1, int32_t v2)
+{
+HELPER_LOG(%s: converting %d to f%d\n, __func__, v2, f1);
+env-fregs[f1].d = int32_to_float64(v2, env-fpu_status);
+}
+
+/* convert 32-bit int to 128-bit float */
+void HELPER(cxfbr)(uint32_t f1, int32_t v2)
+{
+CPU_QuadU v1;
+
+v1.q = int32_to_float128(v2, env-fpu_status);
+env-fregs[f1].ll = v1.ll.upper;
+env-fregs[f1 + 2].ll = v1.ll.lower;
+}
+
+/* convert 64-bit int to 32-bit float */
+void HELPER(cegbr)(uint32_t f1, int64_t v2)
+{
+HELPER_LOG(%s: converting %ld to f%d\n, __func__, v2, f1);
+env-fregs[f1].l.upper = int64_to_float32(v2, env-fpu_status);
+}
+
+/* convert 64-bit int to 64-bit float */
+void 

[Qemu-devel] [PATCH 18/21] target-cris: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure   |2 +-
 target-cris/Makefile.objs   |2 -
 target-cris/helper.c|4 +-
 target-cris/helper.h|   34 
 target-cris/op_helper.c |   89 +--
 target-cris/translate.c |   50 ---
 target-cris/translate_v10.c |   22 +-
 7 files changed, 101 insertions(+), 102 deletions(-)

diff --git a/configure b/configure
index e464d2f..d760e07 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | arm* | i386 | lm32 | m68k | microblaze* | or32 | s390x | sparc* | 
unicore32 | x86_64 | xtensa* | ppc*)
+  alpha | arm* | cris | i386 | lm32 | m68k | microblaze* | or32 | s390x | 
sparc* | unicore32 | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-cris/Makefile.objs b/target-cris/Makefile.objs
index 4b09e8c..afb87bc 100644
--- a/target-cris/Makefile.objs
+++ b/target-cris/Makefile.objs
@@ -1,4 +1,2 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-cris/helper.c b/target-cris/helper.c
index bfbc29e..1bdb7e2 100644
--- a/target-cris/helper.c
+++ b/target-cris/helper.c
@@ -151,7 +151,7 @@ static void do_interruptv10(CPUCRISState *env)
}
 
/* Now that we are in kernel mode, load the handlers address.  */
-   env-pc = ldl_code(env-pregs[PR_EBP] + ex_vec * 4);
+env-pc = cpu_ldl_code(env, env-pregs[PR_EBP] + ex_vec * 4);
env-locked_irq = 1;
env-pregs[PR_CCS] |= F_FLAG_V10; /* set F.  */
 
@@ -233,7 +233,7 @@ void do_interrupt(CPUCRISState *env)
/* Now that we are in kernel mode, load the handlers address.
   This load may not fault, real hw leaves that behaviour as
   undefined.  */
-   env-pc = ldl_code(env-pregs[PR_EBP] + ex_vec * 4);
+env-pc = cpu_ldl_code(env, env-pregs[PR_EBP] + ex_vec * 4);
 
/* Clear the excption_index to avoid spurios hw_aborts for recursive
   bus faults.  */
diff --git a/target-cris/helper.h b/target-cris/helper.h
index 093063a..b575524 100644
--- a/target-cris/helper.h
+++ b/target-cris/helper.h
@@ -1,26 +1,26 @@
 #include def-helper.h
 
-DEF_HELPER_1(raise_exception, void, i32)
-DEF_HELPER_1(tlb_flush_pid, void, i32)
-DEF_HELPER_1(spc_write, void, i32)
+DEF_HELPER_2(raise_exception, void, env, i32)
+DEF_HELPER_2(tlb_flush_pid, void, env, i32)
+DEF_HELPER_2(spc_write, void, env, i32)
 DEF_HELPER_3(dump, void, i32, i32, i32)
-DEF_HELPER_0(rfe, void);
-DEF_HELPER_0(rfn, void);
+DEF_HELPER_1(rfe, void, env);
+DEF_HELPER_1(rfn, void, env);
 
-DEF_HELPER_2(movl_sreg_reg, void, i32, i32)
-DEF_HELPER_2(movl_reg_sreg, void, i32, i32)
+DEF_HELPER_3(movl_sreg_reg, void, env, i32, i32)
+DEF_HELPER_3(movl_reg_sreg, void, env, i32, i32)
 
 DEF_HELPER_FLAGS_1(lz, TCG_CALL_PURE, i32, i32);
-DEF_HELPER_FLAGS_3(btst, TCG_CALL_PURE, i32, i32, i32, i32);
+DEF_HELPER_FLAGS_4(btst, TCG_CALL_PURE, i32, env, i32, i32, i32);
 
-DEF_HELPER_FLAGS_3(evaluate_flags_muls, TCG_CALL_PURE, i32, i32, i32, i32)
-DEF_HELPER_FLAGS_3(evaluate_flags_mulu, TCG_CALL_PURE, i32, i32, i32, i32)
-DEF_HELPER_FLAGS_4(evaluate_flags_mcp, TCG_CALL_PURE, i32, i32, i32, i32, i32)
-DEF_HELPER_FLAGS_4(evaluate_flags_alu_4, TCG_CALL_PURE, i32, i32, i32, i32, 
i32)
-DEF_HELPER_FLAGS_4(evaluate_flags_sub_4, TCG_CALL_PURE, i32, i32, i32, i32, 
i32)
-DEF_HELPER_FLAGS_2(evaluate_flags_move_4, TCG_CALL_PURE, i32, i32, i32)
-DEF_HELPER_FLAGS_2(evaluate_flags_move_2, TCG_CALL_PURE, i32, i32, i32)
-DEF_HELPER_0(evaluate_flags, void)
-DEF_HELPER_0(top_evaluate_flags, void)
+DEF_HELPER_FLAGS_4(evaluate_flags_muls, TCG_CALL_PURE, i32, env, i32, i32, i32)
+DEF_HELPER_FLAGS_4(evaluate_flags_mulu, TCG_CALL_PURE, i32, env, i32, i32, i32)
+DEF_HELPER_FLAGS_5(evaluate_flags_mcp, TCG_CALL_PURE, i32, env, i32, i32, i32, 
i32)
+DEF_HELPER_FLAGS_5(evaluate_flags_alu_4, TCG_CALL_PURE, i32, env, i32, i32, 
i32, i32)
+DEF_HELPER_FLAGS_5(evaluate_flags_sub_4, TCG_CALL_PURE, i32, env, i32, i32, 
i32, i32)
+DEF_HELPER_FLAGS_3(evaluate_flags_move_4, TCG_CALL_PURE, i32, env, i32, i32)
+DEF_HELPER_FLAGS_3(evaluate_flags_move_2, TCG_CALL_PURE, i32, env, i32, i32)
+DEF_HELPER_1(evaluate_flags, void, env)
+DEF_HELPER_1(top_evaluate_flags, void, env)
 
 #include def-helper.h
diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c
index ac7c98c..5cce3e7 100644
--- a/target-cris/op_helper.c
+++ b/target-cris/op_helper.c
@@ -19,7 +19,6 @@
  */
 
 #include cpu.h
-#include dyngen-exec.h
 #include mmu.h
 #include helper.h
 #include host-utils.h
@@ -55,17 +54,12 @@
 /* Try to fill the TLB and return an exception if error. If retaddr is

[Qemu-devel] [PATCH 15/21] target-unicore32: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure  |2 +-
 target-unicore32/Makefile.objs |2 -
 target-unicore32/helper.h  |   26 
 target-unicore32/op_helper.c   |   65 +++
 target-unicore32/translate.c   |   38 +++---
 5 files changed, 58 insertions(+), 75 deletions(-)

diff --git a/configure b/configure
index 350b47c..4fd3b7f 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | i386 | lm32 | m68k | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
+  alpha | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | x86_64 | 
xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-unicore32/Makefile.objs b/target-unicore32/Makefile.objs
index 777f01f..8e143da 100644
--- a/target-unicore32/Makefile.objs
+++ b/target-unicore32/Makefile.objs
@@ -2,5 +2,3 @@ obj-y += translate.o op_helper.o helper.o cpu.o
 obj-y += ucf64_helper.o
 
 obj-$(CONFIG_SOFTMMU) += machine.o softmmu.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h
index 305318a..a4b8149 100644
--- a/target-unicore32/helper.h
+++ b/target-unicore32/helper.h
@@ -17,26 +17,26 @@ DEF_HELPER_1(cp1_putc, void, i32)
 DEF_HELPER_1(clz, i32, i32)
 DEF_HELPER_1(clo, i32, i32)
 
-DEF_HELPER_1(exception, void, i32)
+DEF_HELPER_2(exception, void, env, i32)
 
-DEF_HELPER_2(asr_write, void, i32, i32)
-DEF_HELPER_0(asr_read, i32)
+DEF_HELPER_3(asr_write, void, env, i32, i32)
+DEF_HELPER_1(asr_read, i32, env)
 
-DEF_HELPER_1(get_user_reg, i32, i32)
-DEF_HELPER_2(set_user_reg, void, i32, i32)
+DEF_HELPER_2(get_user_reg, i32, env, i32)
+DEF_HELPER_3(set_user_reg, void, env, i32, i32)
 
-DEF_HELPER_2(add_cc, i32, i32, i32)
-DEF_HELPER_2(adc_cc, i32, i32, i32)
-DEF_HELPER_2(sub_cc, i32, i32, i32)
-DEF_HELPER_2(sbc_cc, i32, i32, i32)
+DEF_HELPER_3(add_cc, i32, env, i32, i32)
+DEF_HELPER_3(adc_cc, i32, env, i32, i32)
+DEF_HELPER_3(sub_cc, i32, env, i32, i32)
+DEF_HELPER_3(sbc_cc, i32, env, i32, i32)
 
 DEF_HELPER_2(shl, i32, i32, i32)
 DEF_HELPER_2(shr, i32, i32, i32)
 DEF_HELPER_2(sar, i32, i32, i32)
-DEF_HELPER_2(shl_cc, i32, i32, i32)
-DEF_HELPER_2(shr_cc, i32, i32, i32)
-DEF_HELPER_2(sar_cc, i32, i32, i32)
-DEF_HELPER_2(ror_cc, i32, i32, i32)
+DEF_HELPER_3(shl_cc, i32, env, i32, i32)
+DEF_HELPER_3(shr_cc, i32, env, i32, i32)
+DEF_HELPER_3(sar_cc, i32, env, i32, i32)
+DEF_HELPER_3(ror_cc, i32, env, i32, i32)
 
 DEF_HELPER_1(ucf64_get_fpscr, i32, env)
 DEF_HELPER_2(ucf64_set_fpscr, void, env, i32)
diff --git a/target-unicore32/op_helper.c b/target-unicore32/op_helper.c
index c63789d..f474d1b 100644
--- a/target-unicore32/op_helper.c
+++ b/target-unicore32/op_helper.c
@@ -9,19 +9,18 @@
  * later version. See the COPYING file in the top-level directory.
  */
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 
 #define SIGNBIT (uint32_t)0x8000
 #define SIGNBIT64 ((uint64_t)1  63)
 
-void HELPER(exception)(uint32_t excp)
+void HELPER(exception)(CPUUniCore32State *env, uint32_t excp)
 {
 env-exception_index = excp;
 cpu_loop_exit(env);
 }
 
-static target_ulong asr_read(void)
+static target_ulong asr_read(CPUUniCore32State *env)
 {
 int ZF;
 ZF = (env-ZF == 0);
@@ -29,24 +28,18 @@ static target_ulong asr_read(void)
 (env-CF  29) | ((env-VF  0x8000)  3);
 }
 
-target_ulong cpu_asr_read(CPUUniCore32State *env1)
+target_ulong cpu_asr_read(CPUUniCore32State *env)
 {
-CPUUniCore32State *saved_env;
-target_ulong ret;
-
-saved_env = env;
-env = env1;
-ret = asr_read();
-env = saved_env;
-return ret;
+return asr_read(env);
 }
 
-target_ulong HELPER(asr_read)(void)
+target_ulong HELPER(asr_read)(CPUUniCore32State *env)
 {
-return asr_read();
+return asr_read(env);
 }
 
-static void asr_write(target_ulong val, target_ulong mask)
+static void asr_write(CPUUniCore32State *env, target_ulong val,
+  target_ulong mask)
 {
 if (mask  ASR_NZCV) {
 env-ZF = (~val)  ASR_Z;
@@ -62,23 +55,19 @@ static void asr_write(target_ulong val, target_ulong mask)
 env-uncached_asr = (env-uncached_asr  ~mask) | (val  mask);
 }
 
-void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong 
mask)
+void cpu_asr_write(CPUUniCore32State *env, target_ulong val, target_ulong mask)
 {
-CPUUniCore32State *saved_env;
-
-saved_env = env;
-env = env1;
-asr_write(val, mask);
-env = saved_env;
+asr_write(env, val, mask);
 }
 
-void HELPER(asr_write)(target_ulong val, target_ulong mask)
+void HELPER(asr_write)(CPUUniCore32State *env, target_ulong val,
+   target_ulong mask)
 {
-asr_write(val, mask);
+asr_write(env, 

[Qemu-devel] [PATCH 14/21] target-m68k: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure |2 +-
 target-m68k/Makefile.objs |2 -
 target-m68k/helpers.h |2 +-
 target-m68k/op_helper.c   |   68 
 target-m68k/translate.c   |   76 +++--
 5 files changed, 68 insertions(+), 82 deletions(-)

diff --git a/configure b/configure
index 9261f68..350b47c 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | i386 | lm32 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
+  alpha | i386 | lm32 | m68k | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-m68k/Makefile.objs b/target-m68k/Makefile.objs
index cda6015..7eccfab 100644
--- a/target-m68k/Makefile.objs
+++ b/target-m68k/Makefile.objs
@@ -1,5 +1,3 @@
 obj-y += m68k-semi.o
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-m68k/helpers.h b/target-m68k/helpers.h
index cb8a0c7..8112b44 100644
--- a/target-m68k/helpers.h
+++ b/target-m68k/helpers.h
@@ -49,6 +49,6 @@ DEF_HELPER_3(set_mac_exts, void, env, i32, i32)
 DEF_HELPER_3(set_mac_extu, void, env, i32, i32)
 
 DEF_HELPER_2(flush_flags, void, env, i32)
-DEF_HELPER_1(raise_exception, void, i32)
+DEF_HELPER_2(raise_exception, void, env, i32)
 
 #include def-helper.h
diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c
index 1971a57..3116287 100644
--- a/target-m68k/op_helper.c
+++ b/target-m68k/op_helper.c
@@ -17,17 +17,16 @@
  * License along with this library; if not, see http://www.gnu.org/licenses/.
  */
 #include cpu.h
-#include dyngen-exec.h
 #include helpers.h
 
 #if defined(CONFIG_USER_ONLY)
 
-void do_interrupt(CPUM68KState *env1)
+void do_interrupt(CPUM68KState *env)
 {
-env1-exception_index = -1;
+env-exception_index = -1;
 }
 
-void do_interrupt_m68k_hardirq(CPUM68KState *env1)
+void do_interrupt_m68k_hardirq(CPUM68KState *env)
 {
 }
 
@@ -54,16 +53,12 @@ extern int semihosting_enabled;
 /* Try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
-/* XXX: fix it to restore all registers */
-void tlb_fill(CPUM68KState *env1, target_ulong addr, int is_write, int mmu_idx,
+void tlb_fill(CPUM68KState *env, target_ulong addr, int is_write, int mmu_idx,
   uintptr_t retaddr)
 {
 TranslationBlock *tb;
-CPUM68KState *saved_env;
 int ret;
 
-saved_env = env;
-env = env1;
 ret = cpu_m68k_handle_mmu_fault(env, addr, is_write, mmu_idx);
 if (unlikely(ret)) {
 if (retaddr) {
@@ -77,24 +72,23 @@ void tlb_fill(CPUM68KState *env1, target_ulong addr, int 
is_write, int mmu_idx,
 }
 cpu_loop_exit(env);
 }
-env = saved_env;
 }
 
-static void do_rte(void)
+static void do_rte(CPUM68KState *env)
 {
 uint32_t sp;
 uint32_t fmt;
 
 sp = env-aregs[7];
-fmt = ldl_kernel(sp);
-env-pc = ldl_kernel(sp + 4);
+fmt = cpu_ldl_kernel(env, sp);
+env-pc = cpu_ldl_kernel(env, sp + 4);
 sp |= (fmt  28)  3;
 env-sr = fmt  0x;
 m68k_switch_sp(env);
 env-aregs[7] = sp + 8;
 }
 
-static void do_interrupt_all(int is_hw)
+static void do_interrupt_all(CPUM68KState *env, int is_hw)
 {
 uint32_t sp;
 uint32_t fmt;
@@ -108,14 +102,14 @@ static void do_interrupt_all(int is_hw)
 switch (env-exception_index) {
 case EXCP_RTE:
 /* Return from an exception.  */
-do_rte();
+do_rte(env);
 return;
 case EXCP_HALT_INSN:
 if (semihosting_enabled
  (env-sr  SR_S) != 0
  (env-pc  3) == 0
- lduw_code(env-pc - 4) == 0x4e71
- ldl_code(env-pc) == 0x4e7bf000) {
+ cpu_lduw_code(env, env-pc - 4) == 0x4e71
+ cpu_ldl_code(env, env-pc) == 0x4e7bf000) {
 env-pc += 4;
 do_m68k_semihosting(env, env-dregs[0]);
 return;
@@ -151,44 +145,34 @@ static void do_interrupt_all(int is_hw)
 /* ??? This could cause MMU faults.  */
 sp = ~3;
 sp -= 4;
-stl_kernel(sp, retaddr);
+cpu_stl_kernel(env, sp, retaddr);
 sp -= 4;
-stl_kernel(sp, fmt);
+cpu_stl_kernel(env, sp, fmt);
 env-aregs[7] = sp;
 /* Jump to vector.  */
-env-pc = ldl_kernel(env-vbr + vector);
+env-pc = cpu_ldl_kernel(env, env-vbr + vector);
 }
 
-void do_interrupt(CPUM68KState *env1)
+void do_interrupt(CPUM68KState *env)
 {
-CPUM68KState *saved_env;
-
-saved_env = env;
-env = env1;
-

[Qemu-devel] [PATCH 08/21] target-s390x: avoid AREG0 for integer helpers

2012-09-02 Thread Blue Swirl
Make integer helpers take a parameter for CPUState instead
of relying on global env.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |1 -
 target-s390x/helper.h  |   10 +-
 target-s390x/int_helper.c  |   12 ++--
 target-s390x/translate.c   |   16 
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 7d965e9..7b2c5c1 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -3,7 +3,6 @@ obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o 
misc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
-$(obj)/int_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/mem_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/misc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/helper.h b/target-s390x/helper.h
index af98773..c03cd59 100644
--- a/target-s390x/helper.h
+++ b/target-s390x/helper.h
@@ -12,8 +12,8 @@ DEF_HELPER_FLAGS_1(set_cc_comp_s64, 
TCG_CALL_PURE|TCG_CALL_CONST, i32, s64)
 DEF_HELPER_FLAGS_2(set_cc_icm, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32)
 DEF_HELPER_3(clm, i32, i32, i32, i64)
 DEF_HELPER_3(stcm, void, i32, i32, i64)
-DEF_HELPER_2(mlg, void, i32, i64)
-DEF_HELPER_2(dlg, void, i32, i64)
+DEF_HELPER_3(mlg, void, env, i32, i64)
+DEF_HELPER_3(dlg, void, env, i32, i64)
 DEF_HELPER_FLAGS_3(set_cc_add64, TCG_CALL_PURE|TCG_CALL_CONST, i32, s64, s64, 
s64)
 DEF_HELPER_FLAGS_3(set_cc_addu64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, i64, 
i64)
 DEF_HELPER_FLAGS_3(set_cc_add32, TCG_CALL_PURE|TCG_CALL_CONST, i32, s32, s32, 
s32)
@@ -43,8 +43,8 @@ DEF_HELPER_3(stam, void, i32, i64, i32)
 DEF_HELPER_3(lam, void, i32, i64, i32)
 DEF_HELPER_3(mvcle, i32, i32, i64, i32)
 DEF_HELPER_3(clcle, i32, i32, i64, i32)
-DEF_HELPER_3(slb, i32, i32, i32, i32)
-DEF_HELPER_4(slbg, i32, i32, i32, i64, i64)
+DEF_HELPER_4(slb, i32, env, i32, i32, i32)
+DEF_HELPER_5(slbg, i32, env, i32, i32, i64, i64)
 DEF_HELPER_3(cefbr, void, env, i32, s32)
 DEF_HELPER_3(cdfbr, void, env, i32, s32)
 DEF_HELPER_3(cxfbr, void, env, i32, s32)
@@ -107,7 +107,7 @@ DEF_HELPER_3(lxdb, void, env, i32, i64)
 DEF_HELPER_FLAGS_3(tceb, TCG_CALL_PURE, i32, env, i32, i64)
 DEF_HELPER_FLAGS_3(tcdb, TCG_CALL_PURE, i32, env, i32, i64)
 DEF_HELPER_FLAGS_3(tcxb, TCG_CALL_PURE, i32, env, i32, i64)
-DEF_HELPER_2(flogr, i32, i32, i64)
+DEF_HELPER_3(flogr, i32, env, i32, i64)
 DEF_HELPER_3(sqdbr, void, env, i32, i32)
 DEF_HELPER_FLAGS_1(cvd, TCG_CALL_PURE|TCG_CALL_CONST, i64, s32)
 DEF_HELPER_3(unpk, void, i32, i64, i64)
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index e2eeb07..f202a7e 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -19,7 +19,6 @@
  */
 
 #include cpu.h
-#include dyngen-exec.h
 #include host-utils.h
 #include helper.h
 
@@ -31,7 +30,7 @@
 #endif
 
 /* 64/64 - 128 unsigned multiplication */
-void HELPER(mlg)(uint32_t r1, uint64_t v2)
+void HELPER(mlg)(CPUS390XState *env, uint32_t r1, uint64_t v2)
 {
 #if HOST_LONG_BITS == 64  defined(__GNUC__)
 /* assuming 64-bit hosts have __uint128_t */
@@ -46,7 +45,7 @@ void HELPER(mlg)(uint32_t r1, uint64_t v2)
 }
 
 /* 128 - 64/64 unsigned division */
-void HELPER(dlg)(uint32_t r1, uint64_t v2)
+void HELPER(dlg)(CPUS390XState *env, uint32_t r1, uint64_t v2)
 {
 uint64_t divisor = v2;
 
@@ -129,7 +128,7 @@ uint32_t HELPER(addc_u32)(uint32_t cc, uint32_t v1, 
uint32_t v2)
 }
 
 /* subtract unsigned v2 from v1 with borrow */
-uint32_t HELPER(slb)(uint32_t cc, uint32_t r1, uint32_t v2)
+uint32_t HELPER(slb)(CPUS390XState *env, uint32_t cc, uint32_t r1, uint32_t v2)
 {
 uint32_t v1 = env-regs[r1];
 uint32_t res = v1 + (~v2) + (cc  1);
@@ -144,7 +143,8 @@ uint32_t HELPER(slb)(uint32_t cc, uint32_t r1, uint32_t v2)
 }
 
 /* subtract unsigned v2 from v1 with borrow */
-uint32_t HELPER(slbg)(uint32_t cc, uint32_t r1, uint64_t v1, uint64_t v2)
+uint32_t HELPER(slbg)(CPUS390XState *env, uint32_t cc, uint32_t r1,
+  uint64_t v1, uint64_t v2)
 {
 uint64_t res = v1 + (~v2) + (cc  1);
 
@@ -158,7 +158,7 @@ uint32_t HELPER(slbg)(uint32_t cc, uint32_t r1, uint64_t 
v1, uint64_t v2)
 }
 
 /* find leftmost one */
-uint32_t HELPER(flogr)(uint32_t r1, uint64_t v2)
+uint32_t HELPER(flogr)(CPUS390XState *env, uint32_t r1, uint64_t v2)
 {
 uint64_t res = 0;
 uint64_t ov2 = v2;
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index b1f2071..2a61e92 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -1803,7 +1803,7 @@ static void disas_e3(DisasContext* s, int op, int r1, int 
x2, int b2, int d2)
 tmp2 = tcg_temp_new_i64();
 tmp32_1 = tcg_const_i32(r1);
 tcg_gen_qemu_ld64(tmp2, addr, get_mem_index(s));
-gen_helper_mlg(tmp32_1, tmp2);
+gen_helper_mlg(cpu_env, tmp32_1, tmp2);
 tcg_temp_free_i64(tmp2);
  

[Qemu-devel] [PATCH 13/21] target-lm32: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure |2 +-
 target-lm32/Makefile.objs |2 --
 target-lm32/helper.h  |   20 ++--
 target-lm32/op_helper.c   |   29 +++--
 target-lm32/translate.c   |   22 +++---
 5 files changed, 33 insertions(+), 42 deletions(-)

diff --git a/configure b/configure
index a88a465..9261f68 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | i386 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
+  alpha | i386 | lm32 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-lm32/Makefile.objs b/target-lm32/Makefile.objs
index 2e0e093..ca20f21 100644
--- a/target-lm32/Makefile.objs
+++ b/target-lm32/Makefile.objs
@@ -1,4 +1,2 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-lm32/helper.h b/target-lm32/helper.h
index 9d335ef..07f5670 100644
--- a/target-lm32/helper.h
+++ b/target-lm32/helper.h
@@ -1,14 +1,14 @@
 #include def-helper.h
 
-DEF_HELPER_1(raise_exception, void, i32)
-DEF_HELPER_0(hlt, void)
-DEF_HELPER_1(wcsr_im, void, i32)
-DEF_HELPER_1(wcsr_ip, void, i32)
-DEF_HELPER_1(wcsr_jtx, void, i32)
-DEF_HELPER_1(wcsr_jrx, void, i32)
-DEF_HELPER_0(rcsr_im, i32)
-DEF_HELPER_0(rcsr_ip, i32)
-DEF_HELPER_0(rcsr_jtx, i32)
-DEF_HELPER_0(rcsr_jrx, i32)
+DEF_HELPER_2(raise_exception, void, env, i32)
+DEF_HELPER_1(hlt, void, env)
+DEF_HELPER_2(wcsr_im, void, env, i32)
+DEF_HELPER_2(wcsr_ip, void, env, i32)
+DEF_HELPER_2(wcsr_jtx, void, env, i32)
+DEF_HELPER_2(wcsr_jrx, void, env, i32)
+DEF_HELPER_1(rcsr_im, i32, env)
+DEF_HELPER_1(rcsr_ip, i32, env)
+DEF_HELPER_1(rcsr_jtx, i32, env)
+DEF_HELPER_1(rcsr_jrx, i32, env)
 
 #include def-helper.h
diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c
index 51edc1a..7b91d8c 100644
--- a/target-lm32/op_helper.c
+++ b/target-lm32/op_helper.c
@@ -1,6 +1,5 @@
 #include assert.h
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 #include host-utils.h
 
@@ -18,55 +17,55 @@
 #define SHIFT 3
 #include softmmu_template.h
 
-void helper_raise_exception(uint32_t index)
+void helper_raise_exception(CPULM32State *env, uint32_t index)
 {
 env-exception_index = index;
 cpu_loop_exit(env);
 }
 
-void helper_hlt(void)
+void helper_hlt(CPULM32State *env)
 {
 env-halted = 1;
 env-exception_index = EXCP_HLT;
 cpu_loop_exit(env);
 }
 
-void helper_wcsr_im(uint32_t im)
+void helper_wcsr_im(CPULM32State *env, uint32_t im)
 {
 lm32_pic_set_im(env-pic_state, im);
 }
 
-void helper_wcsr_ip(uint32_t im)
+void helper_wcsr_ip(CPULM32State *env, uint32_t im)
 {
 lm32_pic_set_ip(env-pic_state, im);
 }
 
-void helper_wcsr_jtx(uint32_t jtx)
+void helper_wcsr_jtx(CPULM32State *env, uint32_t jtx)
 {
 lm32_juart_set_jtx(env-juart_state, jtx);
 }
 
-void helper_wcsr_jrx(uint32_t jrx)
+void helper_wcsr_jrx(CPULM32State *env, uint32_t jrx)
 {
 lm32_juart_set_jrx(env-juart_state, jrx);
 }
 
-uint32_t helper_rcsr_im(void)
+uint32_t helper_rcsr_im(CPULM32State *env)
 {
 return lm32_pic_get_im(env-pic_state);
 }
 
-uint32_t helper_rcsr_ip(void)
+uint32_t helper_rcsr_ip(CPULM32State *env)
 {
 return lm32_pic_get_ip(env-pic_state);
 }
 
-uint32_t helper_rcsr_jtx(void)
+uint32_t helper_rcsr_jtx(CPULM32State *env)
 {
 return lm32_juart_get_jtx(env-juart_state);
 }
 
-uint32_t helper_rcsr_jrx(void)
+uint32_t helper_rcsr_jrx(CPULM32State *env)
 {
 return lm32_juart_get_jrx(env-juart_state);
 }
@@ -74,17 +73,12 @@ uint32_t helper_rcsr_jrx(void)
 /* Try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
-/* XXX: fix it to restore all registers */
-void tlb_fill(CPULM32State *env1, target_ulong addr, int is_write, int mmu_idx,
+void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
   uintptr_t retaddr)
 {
 TranslationBlock *tb;
-CPULM32State *saved_env;
 int ret;
 
-saved_env = env;
-env = env1;
-
 ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
 if (unlikely(ret)) {
 if (retaddr) {
@@ -98,7 +92,6 @@ void tlb_fill(CPULM32State *env1, target_ulong addr, int 
is_write, int mmu_idx,
 }
 cpu_loop_exit(env);
 }
-env = saved_env;
 }
 #endif
 
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
index 872a2ba..b9ae277 100644
--- a/target-lm32/translate.c
+++ b/target-lm32/translate.c
@@ -116,7 +116,7 @@ static inline void t_gen_raise_exception(DisasContext *dc, 
uint32_t index)
 {
 TCGv_i32 tmp = 

[Qemu-devel] [PATCH 09/21] target-s390x: avoid AREG0 for condition code helpers

2012-09-02 Thread Blue Swirl
Make condition code helpers take a parameter for CPUState instead
of relying on global env.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |1 -
 target-s390x/cc_helper.c   |   11 +--
 target-s390x/helper.h  |   10 +-
 target-s390x/translate.c   |   16 
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index 7b2c5c1..736cf33 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -3,6 +3,5 @@ obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o 
misc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
-$(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/mem_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/misc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index 9c3a2c4..19ef145 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -19,7 +19,6 @@
  */
 
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 
 /* #define DEBUG_HELPER */
@@ -500,14 +499,14 @@ uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, 
uint64_t src, uint64_t dst,
 return do_calc_cc(env, cc_op, src, dst, vr);
 }
 
-uint32_t HELPER(calc_cc)(uint32_t cc_op, uint64_t src, uint64_t dst,
- uint64_t vr)
+uint32_t HELPER(calc_cc)(CPUS390XState *env, uint32_t cc_op, uint64_t src,
+ uint64_t dst, uint64_t vr)
 {
 return do_calc_cc(env, cc_op, src, dst, vr);
 }
 
 /* insert psw mask and condition code into r1 */
-void HELPER(ipm)(uint32_t cc, uint32_t r1)
+void HELPER(ipm)(CPUS390XState *env, uint32_t cc, uint32_t r1)
 {
 uint64_t r = env-regs[r1];
 
@@ -519,13 +518,13 @@ void HELPER(ipm)(uint32_t cc, uint32_t r1)
 }
 
 #ifndef CONFIG_USER_ONLY
-void HELPER(load_psw)(uint64_t mask, uint64_t addr)
+void HELPER(load_psw)(CPUS390XState *env, uint64_t mask, uint64_t addr)
 {
 load_psw(env, mask, addr);
 cpu_loop_exit(env);
 }
 
-void HELPER(sacf)(uint64_t a1)
+void HELPER(sacf)(CPUS390XState *env, uint64_t a1)
 {
 HELPER_LOG(%s: %16 PRIx64 \n, __func__, a1);
 
diff --git a/target-s390x/helper.h b/target-s390x/helper.h
index c03cd59..876b88e 100644
--- a/target-s390x/helper.h
+++ b/target-s390x/helper.h
@@ -36,7 +36,7 @@ DEF_HELPER_FLAGS_1(abs_i64, TCG_CALL_PURE|TCG_CALL_CONST, 
i64, s64)
 DEF_HELPER_FLAGS_1(nabs_i64, TCG_CALL_PURE|TCG_CALL_CONST, s64, s64)
 DEF_HELPER_3(stcmh, void, i32, i64, i32)
 DEF_HELPER_3(icmh, i32, i32, i64, i32)
-DEF_HELPER_2(ipm, void, i32, i32)
+DEF_HELPER_3(ipm, void, env, i32, i32)
 DEF_HELPER_FLAGS_3(addc_u32, TCG_CALL_PURE|TCG_CALL_CONST, i32, i32, i32, i32)
 DEF_HELPER_FLAGS_3(set_cc_addc_u64, TCG_CALL_PURE|TCG_CALL_CONST, i32, i64, 
i64, i64)
 DEF_HELPER_3(stam, void, i32, i64, i32)
@@ -115,7 +115,7 @@ DEF_HELPER_3(tr, void, i32, i64, i64)
 
 DEF_HELPER_2(servc, i32, i32, i64)
 DEF_HELPER_3(diag, i64, i32, i64, i64)
-DEF_HELPER_2(load_psw, void, i64, i64)
+DEF_HELPER_3(load_psw, void, env, i64, i64)
 DEF_HELPER_1(program_interrupt, void, i32)
 DEF_HELPER_FLAGS_1(stidp, TCG_CALL_CONST, void, i64)
 DEF_HELPER_FLAGS_1(spx, TCG_CALL_CONST, void, i64)
@@ -139,14 +139,14 @@ DEF_HELPER_2(csp, i32, i32, i32)
 DEF_HELPER_3(mvcs, i32, i64, i64, i64)
 DEF_HELPER_3(mvcp, i32, i64, i64, i64)
 DEF_HELPER_3(sigp, i32, i64, i32, i64)
-DEF_HELPER_1(sacf, void, i64)
+DEF_HELPER_2(sacf, void, env, i64)
 DEF_HELPER_FLAGS_2(ipte, TCG_CALL_CONST, void, i64, i64)
 DEF_HELPER_FLAGS_0(ptlb, TCG_CALL_CONST, void)
 DEF_HELPER_2(lra, i32, i64, i32)
 DEF_HELPER_2(stura, void, i64, i32)
 DEF_HELPER_2(cksm, void, i32, i32)
 
-DEF_HELPER_FLAGS_4(calc_cc, TCG_CALL_PURE|TCG_CALL_CONST,
-   i32, i32, i64, i64, i64)
+DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_PURE|TCG_CALL_CONST,
+   i32, env, i32, i64, i64, i64)
 
 #include def-helper.h
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 2a61e92..1d87272 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -722,7 +722,7 @@ static void gen_op_calc_cc(DisasContext *s)
 case CC_OP_NZ_F32:
 case CC_OP_NZ_F64:
 /* 1 argument */
-gen_helper_calc_cc(cc_op, local_cc_op, dummy, cc_dst, dummy);
+gen_helper_calc_cc(cc_op, cpu_env, local_cc_op, dummy, cc_dst, dummy);
 break;
 case CC_OP_ICM:
 case CC_OP_LTGT_32:
@@ -735,7 +735,7 @@ static void gen_op_calc_cc(DisasContext *s)
 case CC_OP_LTGT_F64:
 case CC_OP_SLAG:
 /* 2 arguments */
-gen_helper_calc_cc(cc_op, local_cc_op, cc_src, cc_dst, dummy);
+gen_helper_calc_cc(cc_op, cpu_env, local_cc_op, cc_src, cc_dst, dummy);
 break;
 case CC_OP_ADD_64:
 case CC_OP_ADDU_64:
@@ -746,11 +746,11 @@ static void gen_op_calc_cc(DisasContext *s)
 case CC_OP_SUB_32:
 case CC_OP_SUBU_32:
 /* 3 arguments */
-gen_helper_calc_cc(cc_op, local_cc_op, 

[Qemu-devel] [PATCH 04/21] target-s390x: split integer helpers

2012-09-02 Thread Blue Swirl
Move integer helpers to int_helper.c.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |3 +-
 target-s390x/int_helper.c  |  201 
 target-s390x/op_helper.c   |  170 -
 3 files changed, 203 insertions(+), 171 deletions(-)
 create mode 100644 target-s390x/int_helper.c

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index f9437d6..e8f66e9 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -1,8 +1,9 @@
 obj-y += translate.o op_helper.o helper.o cpu.o interrupt.o
-obj-y += fpu_helper.o cc_helper.o
+obj-y += int_helper.o fpu_helper.o cc_helper.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
 $(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
+$(obj)/int_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/fpu_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
new file mode 100644
index 000..e2eeb07
--- /dev/null
+++ b/target-s390x/int_helper.c
@@ -0,0 +1,201 @@
+/*
+ *  S/390 integer helper routines
+ *
+ *  Copyright (c) 2009 Ulrich Hecht
+ *  Copyright (c) 2009 Alexander Graf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see http://www.gnu.org/licenses/.
+ */
+
+#include cpu.h
+#include dyngen-exec.h
+#include host-utils.h
+#include helper.h
+
+/* #define DEBUG_HELPER */
+#ifdef DEBUG_HELPER
+#define HELPER_LOG(x...) qemu_log(x)
+#else
+#define HELPER_LOG(x...)
+#endif
+
+/* 64/64 - 128 unsigned multiplication */
+void HELPER(mlg)(uint32_t r1, uint64_t v2)
+{
+#if HOST_LONG_BITS == 64  defined(__GNUC__)
+/* assuming 64-bit hosts have __uint128_t */
+__uint128_t res = (__uint128_t)env-regs[r1 + 1];
+
+res *= (__uint128_t)v2;
+env-regs[r1] = (uint64_t)(res  64);
+env-regs[r1 + 1] = (uint64_t)res;
+#else
+mulu64(env-regs[r1 + 1], env-regs[r1], env-regs[r1 + 1], v2);
+#endif
+}
+
+/* 128 - 64/64 unsigned division */
+void HELPER(dlg)(uint32_t r1, uint64_t v2)
+{
+uint64_t divisor = v2;
+
+if (!env-regs[r1]) {
+/* 64 - 64/64 case */
+env-regs[r1] = env-regs[r1 + 1] % divisor;
+env-regs[r1 + 1] = env-regs[r1 + 1] / divisor;
+return;
+} else {
+#if HOST_LONG_BITS == 64  defined(__GNUC__)
+/* assuming 64-bit hosts have __uint128_t */
+__uint128_t dividend = (((__uint128_t)env-regs[r1])  64) |
+(env-regs[r1 + 1]);
+__uint128_t quotient = dividend / divisor;
+__uint128_t remainder = dividend % divisor;
+
+env-regs[r1 + 1] = quotient;
+env-regs[r1] = remainder;
+#else
+/* 32-bit hosts would need special wrapper functionality - just abort 
if
+   we encounter such a case; it's very unlikely anyways. */
+cpu_abort(env, 128 - 64/64 division not implemented\n);
+#endif
+}
+}
+
+/* absolute value 32-bit */
+uint32_t HELPER(abs_i32)(int32_t val)
+{
+if (val  0) {
+return -val;
+} else {
+return val;
+}
+}
+
+/* negative absolute value 32-bit */
+int32_t HELPER(nabs_i32)(int32_t val)
+{
+if (val  0) {
+return val;
+} else {
+return -val;
+}
+}
+
+/* absolute value 64-bit */
+uint64_t HELPER(abs_i64)(int64_t val)
+{
+HELPER_LOG(%s: val 0x% PRIx64 \n, __func__, val);
+
+if (val  0) {
+return -val;
+} else {
+return val;
+}
+}
+
+/* negative absolute value 64-bit */
+int64_t HELPER(nabs_i64)(int64_t val)
+{
+if (val  0) {
+return val;
+} else {
+return -val;
+}
+}
+
+/* add with carry 32-bit unsigned */
+uint32_t HELPER(addc_u32)(uint32_t cc, uint32_t v1, uint32_t v2)
+{
+uint32_t res;
+
+res = v1 + v2;
+if (cc  2) {
+res++;
+}
+
+return res;
+}
+
+/* subtract unsigned v2 from v1 with borrow */
+uint32_t HELPER(slb)(uint32_t cc, uint32_t r1, uint32_t v2)
+{
+uint32_t v1 = env-regs[r1];
+uint32_t res = v1 + (~v2) + (cc  1);
+
+env-regs[r1] = (env-regs[r1]  0xULL) | res;
+if (cc  2) {
+/* borrow */
+return v1 ? 1 : 0;
+} else {
+return v1 ? 3 : 2;
+}
+}
+
+/* subtract unsigned v2 from v1 with borrow */
+uint32_t HELPER(slbg)(uint32_t cc, uint32_t r1, uint64_t v1, uint64_t v2)
+{
+uint64_t res = 

[Qemu-devel] [PATCH 07/21] target-s390x: avoid AREG0 for FPU helpers

2012-09-02 Thread Blue Swirl
Make FPU helpers take a parameter for CPUState instead
of relying on global env.

Introduce temporary wrappers for FPU load and store ops.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 target-s390x/Makefile.objs |1 -
 target-s390x/cc_helper.c   |4 +-
 target-s390x/cpu.h |   14 +++-
 target-s390x/fpu_helper.c  |  184 +++-
 target-s390x/helper.h  |  126 +++---
 target-s390x/mem_helper.c  |   49 
 target-s390x/translate.c   |   70 
 7 files changed, 257 insertions(+), 191 deletions(-)

diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
index a87d26f..7d965e9 100644
--- a/target-s390x/Makefile.objs
+++ b/target-s390x/Makefile.objs
@@ -4,7 +4,6 @@ obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
 
 $(obj)/int_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
-$(obj)/fpu_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/cc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/mem_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 $(obj)/misc_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index 2ac1659..9c3a2c4 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -473,10 +473,10 @@ static inline uint32_t do_calc_cc(CPUS390XState *env, 
uint32_t cc_op,
 break;
 
 case CC_OP_LTGT_F32:
-r = set_cc_f32(src, dst);
+r = set_cc_f32(env, src, dst);
 break;
 case CC_OP_LTGT_F64:
-r = set_cc_f64(src, dst);
+r = set_cc_f64(env, src, dst);
 break;
 case CC_OP_NZ_F32:
 r = set_cc_nz_f32(dst);
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 0ccb551..9b7a2e3 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -1000,12 +1000,22 @@ static inline void cpu_pc_from_tb(CPUS390XState *env, 
TranslationBlock* tb)
 }
 
 /* fpu_helper.c */
-uint32_t set_cc_f32(float32 v1, float32 v2);
-uint32_t set_cc_f64(float64 v1, float64 v2);
+uint32_t set_cc_f32(CPUS390XState *env, float32 v1, float32 v2);
+uint32_t set_cc_f64(CPUS390XState *env, float64 v1, float64 v2);
 uint32_t set_cc_nz_f32(float32 v);
 uint32_t set_cc_nz_f64(float64 v);
 
 /* misc_helper.c */
 void program_interrupt(CPUS390XState *env, uint32_t code, int ilc);
 
+/* temporary wrappers */
+uint32_t cpu_ldub_data(CPUS390XState *env, target_ulong ptr);
+uint32_t cpu_lduw_data(CPUS390XState *env, target_ulong ptr);
+uint32_t cpu_ldl_data(CPUS390XState *env, target_ulong ptr);
+uint64_t cpu_ldq_data(CPUS390XState *env, target_ulong ptr);
+
+void cpu_stb_data(CPUS390XState *env, target_ulong ptr, uint32_t data);
+void cpu_stw_data(CPUS390XState *env, target_ulong ptr, uint32_t data);
+void cpu_stl_data(CPUS390XState *env, target_ulong ptr, uint32_t data);
+void cpu_stq_data(CPUS390XState *env, target_ulong ptr, uint64_t data);
 #endif
diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c
index 1389052..e235419 100644
--- a/target-s390x/fpu_helper.c
+++ b/target-s390x/fpu_helper.c
@@ -19,10 +19,10 @@
  */
 
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 
-#if !defined(CONFIG_USER_ONLY)
+/* temporarily disabled due to wrapper use */
+#if 0  !defined(CONFIG_USER_ONLY)
 #include softmmu_exec.h
 #endif
 
@@ -33,7 +33,7 @@
 #define HELPER_LOG(x...)
 #endif
 
-static inline int float_comp_to_cc(int float_compare)
+static inline int float_comp_to_cc(CPUS390XState *env, int float_compare)
 {
 switch (float_compare) {
 case float_relation_equal:
@@ -50,14 +50,16 @@ static inline int float_comp_to_cc(int float_compare)
 }
 
 /* condition codes for binary FP ops */
-uint32_t set_cc_f32(float32 v1, float32 v2)
+uint32_t set_cc_f32(CPUS390XState *env, float32 v1, float32 v2)
 {
-return float_comp_to_cc(float32_compare_quiet(v1, v2, env-fpu_status));
+return float_comp_to_cc(env, float32_compare_quiet(v1, v2,
+   env-fpu_status));
 }
 
-uint32_t set_cc_f64(float64 v1, float64 v2)
+uint32_t set_cc_f64(CPUS390XState *env, float64 v1, float64 v2)
 {
-return float_comp_to_cc(float64_compare_quiet(v1, v2, env-fpu_status));
+return float_comp_to_cc(env, float64_compare_quiet(v1, v2,
+   env-fpu_status));
 }
 
 /* condition codes for unary FP ops */
@@ -101,14 +103,14 @@ static uint32_t set_cc_nz_f128(float128 v)
 }
 
 /* convert 32-bit int to 64-bit float */
-void HELPER(cdfbr)(uint32_t f1, int32_t v2)
+void HELPER(cdfbr)(CPUS390XState *env, uint32_t f1, int32_t v2)
 {
 HELPER_LOG(%s: converting %d to f%d\n, __func__, v2, f1);
 env-fregs[f1].d = int32_to_float64(v2, env-fpu_status);
 }
 
 /* convert 32-bit int to 128-bit float */
-void HELPER(cxfbr)(uint32_t f1, int32_t v2)
+void HELPER(cxfbr)(CPUS390XState *env, uint32_t f1, int32_t v2)
 {
 CPU_QuadU v1;
 
@@ -118,21 +120,21 @@ void HELPER(cxfbr)(uint32_t f1, int32_t v2)
 }
 
 /* convert 

Re: [Qemu-devel] [PATCH] ioh3420: Remove unreachable code

2012-09-02 Thread Juan Quintela
Stefan Weil s...@weilnetz.de wrote:
 Report from smatch:
 hw/ioh3420.c:128 ioh3420_initfn(35) info: ignoring unreachable code.

 Signed-off-by: Stefan Weil s...@weilnetz.de

Reviewed-by: Juan Quintela quint...@redhat.com 



[Qemu-devel] Howto add emulated i2c device

2012-09-02 Thread Peter Hüwe
Hi,

I'd like to add an emulated i2c device to one of the qemu arm platforms, so I 
can use this emulated device to devel a linux kernel driver using this dummy 
as  my test target.

What would be the best way to add such a device?
Is there a simple device available which I can use as a reference?
I already saw that there are some i2c devices available but I'm not sure which 
would be the most appropriate one to start.

Any pointers would be appreciated.

Thanks,
Peter



Re: [Qemu-devel] Detecting context switch in QEMU

2012-09-02 Thread Xin Tong
On Sun, Sep 2, 2012 at 8:52 AM, Xin Tong xerox.time.t...@gmail.com wrote:
 On Sat, Sep 1, 2012 at 10:52 PM, Mulyadi Santosa
 mulyadi.sant...@gmail.com wrote:
 On Sun, Sep 2, 2012 at 2:33 AM, Xin Tong xerox.time.t...@gmail.com wrote:
 I want to detect context switches in QEMU x86_64-softmmu. one of the
 ideas i have is to track the write to CR3. is this valid on QEMU  (
 i.e. are their any cases in which the assumption could break).


 CMIIW, if context switch happen from a parent process to its NPTL
 based thread, or to kernel thread, then CR3 won't be updated since
 they are using the same address space in Linux kernel, right?

BTW, if a thread makes a system call, when the kernel is servicing the
syscall. is it still accessing the thread's memory using the threads
page table (i.e. the kernel is using virtual address ?). how about AIO
kernel threads  ?

Xin

 And that includes no TLB flush AFAIK.

 Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ?

 Xin


 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com



Re: [Qemu-devel] boot device order has no effect for virtio-scsi devices

2012-09-02 Thread ching
On 08/30/2012 07:31 PM, ching wrote:
 My host is Gentoo x64, kernel 3.5.2, qemu-kvm 1.1.1-r1, libvirt 0.9.13, 
 seabios 1.7.0

 i try to set the boot order with scsi cd-rom first, then scsi harddisk

 but the virtual machine will always boot with first scsi device only 
 (unit='0', the scsi harddisk)

 is it a known problem?

 my libvirt config:

 domain type='kvm'
   nameLinux/name
   uuidxxx/uuid
   memory unit='KiB'1048576/memory
   currentMemory unit='KiB'1048576/currentMemory
   vcpu placement='static'2/vcpu
   os
 type arch='x86_64' machine='pc-1.1'hvm/type
 boot dev='cdrom'/
 boot dev='hd'/
 bootmenu enable='no'/
   /os
   features
 acpi/
 apic/
 hap/
   /features
   cpu mode='host-model'
 model fallback='allow'/
   /cpu
   clock offset='utc'/
   on_poweroffdestroy/on_poweroff
   on_rebootrestart/on_reboot
   on_crashrestart/on_crash
   devices
 emulator/usr/bin/qemu-kvm/emulator
 disk type='file' device='disk'
   driver name='qemu' type='raw' cache='unsafe' io='native'/
   source file='/Linux.raw_image'/
   target dev='sda' bus='scsi'/
   address type='drive' controller='0' bus='0' target='0' unit='0'/
 /disk
 disk type='file' device='cdrom'
   driver name='qemu' type='raw' cache='unsafe' io='native'/
   source file='/xubuntu-12.04-desktop-amd64.iso'/
   target dev='sdb' bus='scsi'/
   readonly/
   address type='drive' controller='0' bus='0' target='0' unit='1'/
 /disk
 controller type='usb' index='0'
   address type='pci' domain='0x' bus='0x00' slot='0x01' 
 function='0x2'/
 /controller
 controller type='virtio-serial' index='0'
   address type='pci' domain='0x' bus='0x00' slot='0x04' 
 function='0x0'/
 /controller
 controller type='scsi' index='0' model='virtio-scsi'
   address type='pci' domain='0x' bus='0x00' slot='0x05' 
 function='0x0'/
 /controller
 interface type='direct'
   mac address='xx'/
   source dev='eth0' mode='bridge'/
   model type='virtio'/
   address type='pci' domain='0x' bus='0x00' slot='0x08' 
 function='0x0'/
 /interface
 serial type='pty'
   target port='0'/
 /serial
 console type='pty'
   target type='serial' port='0'/
 /console
 channel type='spicevmc'
   target type='virtio' name='com.redhat.spice.0'/
   address type='virtio-serial' controller='0' bus='0' port='1'/
 /channel
 input type='mouse' bus='ps2'/
 graphics type='spice' autoport='yes'
   image compression='off'/
   jpeg compression='never'/
   zlib compression='never'/
   playback compression='off'/
   streaming mode='off'/
 /graphics
 sound model='ich6'
   codec type='micro'/
   address type='pci' domain='0x' bus='0x00' slot='0x03' 
 function='0x0'/
 /sound
 video
   model type='qxl' vram='65536' heads='1'/
   address type='pci' domain='0x' bus='0x00' slot='0x02' 
 function='0x0'/
 /video
 redirdev bus='usb' type='spicevmc'
 /redirdev
 memballoon model='virtio'
   address type='pci' domain='0x' bus='0x00' slot='0x06' 
 function='0x0'/
 /memballoon
   /devices
 /domain

have anyone tested the boot order of virtio-scsi devices?

os
type arch='x86_64' machine='pc-1.1'hvm/type
boot dev='cdrom'/
boot dev='hd'/
bootmenu enable='no'/
  /os


i try to set the boot order with scsi cd-rom first, then scsi harddisk

but the virtual machine will always boot with first scsi device only (unit='0', 
the scsi harddisk)

is it a known problem?





[Qemu-devel] [PATCH v2 0/4] CHECKPATCH: Add warning for single else statement.

2012-09-02 Thread Don Slutz
Also add more debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Using:

  rm zz;
  for k in 0 1 2 3; do
   for i in 0 1 2 3 4 5 6 7 8 9; do
for j in 0 1 2 3 4 5 6 7 8 9; do
 echo $k$i$j;
 git show HEAD~$k$i$j /tmp/a;
 head -1 /tmp/a zz;
 ./scripts/checkpatch.pl --root=. /tmp/a zz;
done;
   done;
  done

With both the new and old versions that the same warnigns and errors were 
reported.

Don Slutz (4):
  CHECKPATCH: Add --debug adv_dcs
  CHECKPATCH: Add --debug adv_checking
  CHECKPATCH: Add --debug adv_apw
  CHECKPATCH: Add warning for single else statement.

 scripts/checkpatch.pl |   68 
 1 files changed, 45 insertions(+), 23 deletions(-)




[Qemu-devel] [PATCH v2 4/4] CHECKPATCH: Add warning for single else statement.

2012-09-02 Thread Don Slutz
For an example:

WARNING: braces {} are necessary even for single statement blocks
+} else
+return env-regs[R_EAX];

total: 0 errors, 1 warnings, 41 lines checked
Signed-off-by: Don Slutz d...@cloudswitch.com
---
 scripts/checkpatch.pl |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7ec8846..ec0aa4c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2547,12 +2547,16 @@ sub process {
$line !~ /\#\s*else/) {
my $allowed = 0;
 
-   # Check the pre-context.
-   if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
-print APW: ALLOWED: pre$pre line$line\n
-if $dbg_adv_apw;
-$allowed = 1;
-   }
+# Check the pre-context.
+if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
+my $pre = $1;
+
+if ($line !~ /else/) {
+print APW: ALLOWED: pre$pre line$line\n
+if $dbg_adv_apw;
+$allowed = 1;
+}
+}
 
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, $-[0]);
-- 
1.7.1




[Qemu-devel] [PATCH v2 2/4] CHECKPATCH: Add --debug adv_checking

2012-09-02 Thread Don Slutz
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz d...@cloudswitch.com
---
 scripts/checkpatch.pl |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 0b0f3f3..8c83b56 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -98,6 +98,7 @@ my $dbg_possible = 0;
 my $dbg_type = 0;
 my $dbg_attr = 0;
 my $dbg_adv_dcs = 0;
+my $dbg_adv_checking = 0;
 for my $key (keys %debug) {
## no critic
eval \${dbg_$key} = '$debug{$key}';;
@@ -2549,7 +2550,8 @@ sub process {
 
# Check the condition.
my ($cond, $block) = @{$chunks[0]};
-   #print CHECKING$linenr cond$cond block$block\n;
+print CHECKING$linenr cond$cond block$block\n
+if $dbg_adv_checking;
if (defined $cond) {
substr($block, 0, length($cond), '');
}
-- 
1.7.1




[Qemu-devel] [PATCH v2 3/4] CHECKPATCH: Add --debug adv_apw

2012-09-02 Thread Don Slutz
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz d...@cloudswitch.com
---
 scripts/checkpatch.pl |   51 ++--
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8c83b56..7ec8846 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -99,6 +99,7 @@ my $dbg_type = 0;
 my $dbg_attr = 0;
 my $dbg_adv_dcs = 0;
 my $dbg_adv_checking = 0;
+my $dbg_adv_apw = 0;
 for my $key (keys %debug) {
## no critic
eval \${dbg_$key} = '$debug{$key}';;
@@ -2488,8 +2489,11 @@ sub process {
if ($line =~ /(^.*)\bif\b/  $line !~ /\#\s*if/) {
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, 1);
-   #print chunks$#chunks linenr$linenr endln$endln 
level$level\n;
-   #print APW: $chunks[1][0]$chunks[1][1]\n;
+if ($dbg_adv_apw) {
+print APW: chunks$#chunks linenr$linenr 
endln$endln level$level\n;
+print APW: $chunks[1][0]$chunks[1][1]\n
+if $#chunks = 1;
+}
if ($#chunks = 0  $level == 0) {
my $allowed = 0;
my $seen = 0;
@@ -2514,18 +2518,22 @@ sub process {
 
$seen++ if ($block =~ /^\s*{/);
 
-   #print cond$cond block$block 
allowed$allowed\n;
+print APW: cond$cond block$block 
allowed$allowed\n
+if $dbg_adv_apw;
if (statement_lines($cond)  1) {
-   #print APW: ALLOWED: 
cond$cond\n;
-   $allowed = 1;
+print APW: ALLOWED: cond$cond\n
+if $dbg_adv_apw;
+$allowed = 1;
}
if ($block =~/\b(?:if|for|while)\b/) {
-   #print APW: ALLOWED: 
block$block\n;
-   $allowed = 1;
+print APW: ALLOWED: 
block$block\n
+if $dbg_adv_apw;
+$allowed = 1;
}
if (statement_block_size($block)  1) {
-   #print APW: ALLOWED: lines 
block$block\n;
-   $allowed = 1;
+print APW: ALLOWED: lines 
block$block\n
+if $dbg_adv_apw;
+$allowed = 1;
}
}
if ($seen != ($#chunks + 1)) {
@@ -2541,8 +2549,9 @@ sub process {
 
# Check the pre-context.
if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
-   #print APW: ALLOWED: pre$1\n;
-   $allowed = 1;
+print APW: ALLOWED: pre$pre line$line\n
+if $dbg_adv_apw;
+$allowed = 1;
}
 
my ($level, $endln, @chunks) =
@@ -2556,16 +2565,19 @@ sub process {
substr($block, 0, length($cond), '');
}
if (statement_lines($cond)  1) {
-   #print APW: ALLOWED: cond$cond\n;
-   $allowed = 1;
+print APW: ALLOWED: cond$cond\n
+if $dbg_adv_apw;
+$allowed = 1;
}
if ($block =~/\b(?:if|for|while)\b/) {
-   #print APW: ALLOWED: block$block\n;
-   $allowed = 1;
+print APW: ALLOWED: block$block\n
+if $dbg_adv_apw;
+$allowed = 1;
}
if (statement_block_size($block)  1) {
-   #print APW: ALLOWED: lines block$block\n;
-   $allowed = 1;
+print APW: ALLOWED: lines block$block\n
+ 

[Qemu-devel] [PATCH v2 1/4] CHECKPATCH: Add --debug adv_dcs

2012-09-02 Thread Don Slutz
Add debug options to find this issue.  They were not listed
in the help because the are not simple to understand the output of.

Signed-off-by: Don Slutz d...@cloudswitch.com
---
 scripts/checkpatch.pl |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b98dc6c..0b0f3f3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -97,6 +97,7 @@ my $dbg_values = 0;
 my $dbg_possible = 0;
 my $dbg_type = 0;
 my $dbg_attr = 0;
+my $dbg_adv_dcs = 0;
 for my $key (keys %debug) {
## no critic
eval \${dbg_$key} = '$debug{$key}';;
@@ -2575,6 +2576,8 @@ sub process {
$allowed = 1;
}
}
+print DCS: level=$level block$block 
allowed=$allowed\n
+if $dbg_adv_dcs;
if ($level == 0  $block !~ /^\s*\{/  !$allowed) {
my $herectx = $here . \n;;
my $cnt = statement_rawlines($block);
-- 
1.7.1




Re: [Qemu-devel] [PATCH] target-i386: Report on error during cpu_x86_register().

2012-09-02 Thread Don Slutz

Blue Swirl wrote:

On Sat, Sep 1, 2012 at 8:47 PM, Don Slutz d...@cloudswitch.com wrote:
  

Send it to stderr before free of the details.

Signed-off-by: Don Slutz d...@cloudswitch.com
---
 target-i386/cpu.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 57c064f..5c0fef1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1352,6 +1352,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
 }
 object_property_set_str(OBJECT(cpu), def-model_id, model-id, error);
 if (error_is_set(error)) {
+fprintf(stderr, %s: %s\n, __FUNCTION__, error_get_pretty(error));



__func__ is preferred by checkpatch.pl and also GCC recommends using it:
http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html

  

 error_free(error);
 return -1;
 }
--
1.7.1




Somehow I forgot to run checkpatch.pl on this.  V2 soon.
  -Don



Re: [Qemu-devel] [PATCH 19/21] target-sh4: switch to AREG0 free mode

2012-09-02 Thread Aurelien Jarno
On Sun, Sep 02, 2012 at 05:33:48PM +, Blue Swirl wrote:
 Add an explicit CPUState parameter instead of relying on AREG0
 and switch to AREG0 free mode.
 
 Signed-off-by: Blue Swirl blauwir...@gmail.com
 ---
  configure|2 +-
  target-sh4/Makefile.objs |2 -
  target-sh4/helper.h  |   84 +++---
  target-sh4/op_helper.c   |  182 ++---
  target-sh4/translate.c   |  114 -
  5 files changed, 195 insertions(+), 189 deletions(-)
 
 diff --git a/configure b/configure
 index d760e07..d69e43e 100755
 --- a/configure
 +++ b/configure
 @@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
 $target_dir/Makefile
  
  
  case $target_arch2 in
 -  alpha | arm* | cris | i386 | lm32 | m68k | microblaze* | or32 | s390x | 
 sparc* | unicore32 | x86_64 | xtensa* | ppc*)
 +  alpha | arm* | cris | i386 | lm32 | m68k | microblaze* | or32 | s390x | 
 sh4* | sparc* | unicore32 | x86_64 | xtensa* | ppc*)
  echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
;;
  esac
 diff --git a/target-sh4/Makefile.objs b/target-sh4/Makefile.objs
 index 2e0e093..ca20f21 100644
 --- a/target-sh4/Makefile.objs
 +++ b/target-sh4/Makefile.objs
 @@ -1,4 +1,2 @@
  obj-y += translate.o op_helper.o helper.o cpu.o
  obj-$(CONFIG_SOFTMMU) += machine.o
 -
 -$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 diff --git a/target-sh4/helper.h b/target-sh4/helper.h
 index 95e3c7c..6e4f108 100644
 --- a/target-sh4/helper.h
 +++ b/target-sh4/helper.h
 @@ -1,54 +1,54 @@
  #include def-helper.h
  
 -DEF_HELPER_0(ldtlb, void)
 -DEF_HELPER_0(raise_illegal_instruction, void)
 -DEF_HELPER_0(raise_slot_illegal_instruction, void)
 -DEF_HELPER_0(raise_fpu_disable, void)
 -DEF_HELPER_0(raise_slot_fpu_disable, void)
 -DEF_HELPER_0(debug, void)
 -DEF_HELPER_1(sleep, void, i32)
 -DEF_HELPER_1(trapa, void, i32)
 +DEF_HELPER_1(ldtlb, void, env)
 +DEF_HELPER_1(raise_illegal_instruction, void, env)
 +DEF_HELPER_1(raise_slot_illegal_instruction, void, env)
 +DEF_HELPER_1(raise_fpu_disable, void, env)
 +DEF_HELPER_1(raise_slot_fpu_disable, void, env)
 +DEF_HELPER_1(debug, void, env)
 +DEF_HELPER_2(sleep, void, env, i32)
 +DEF_HELPER_2(trapa, void, env, i32)
  
 -DEF_HELPER_2(movcal, void, i32, i32)
 -DEF_HELPER_0(discard_movcal_backup, void)
 -DEF_HELPER_1(ocbi, void, i32)
 +DEF_HELPER_3(movcal, void, env, i32, i32)
 +DEF_HELPER_1(discard_movcal_backup, void, env)
 +DEF_HELPER_2(ocbi, void, env, i32)
  
 -DEF_HELPER_2(addv, i32, i32, i32)
 -DEF_HELPER_2(addc, i32, i32, i32)
 -DEF_HELPER_2(subv, i32, i32, i32)
 -DEF_HELPER_2(subc, i32, i32, i32)
 -DEF_HELPER_2(div1, i32, i32, i32)
 -DEF_HELPER_2(macl, void, i32, i32)
 -DEF_HELPER_2(macw, void, i32, i32)
 +DEF_HELPER_3(addv, i32, env, i32, i32)
 +DEF_HELPER_3(addc, i32, env, i32, i32)
 +DEF_HELPER_3(subv, i32, env, i32, i32)
 +DEF_HELPER_3(subc, i32, env, i32, i32)
 +DEF_HELPER_3(div1, i32, env, i32, i32)
 +DEF_HELPER_3(macl, void, env, i32, i32)
 +DEF_HELPER_3(macw, void, env, i32, i32)
  
 -DEF_HELPER_1(ld_fpscr, void, i32)
 +DEF_HELPER_2(ld_fpscr, void, env, i32)
  
  DEF_HELPER_1(fabs_FT, f32, f32)
  DEF_HELPER_1(fabs_DT, f64, f64)
 -DEF_HELPER_2(fadd_FT, f32, f32, f32)
 -DEF_HELPER_2(fadd_DT, f64, f64, f64)
 -DEF_HELPER_1(fcnvsd_FT_DT, f64, f32)
 -DEF_HELPER_1(fcnvds_DT_FT, f32, f64)
 +DEF_HELPER_3(fadd_FT, f32, env, f32, f32)
 +DEF_HELPER_3(fadd_DT, f64, env, f64, f64)
 +DEF_HELPER_2(fcnvsd_FT_DT, f64, env, f32)
 +DEF_HELPER_2(fcnvds_DT_FT, f32, env, f64)
  
 -DEF_HELPER_2(fcmp_eq_FT, void, f32, f32)
 -DEF_HELPER_2(fcmp_eq_DT, void, f64, f64)
 -DEF_HELPER_2(fcmp_gt_FT, void, f32, f32)
 -DEF_HELPER_2(fcmp_gt_DT, void, f64, f64)
 -DEF_HELPER_2(fdiv_FT, f32, f32, f32)
 -DEF_HELPER_2(fdiv_DT, f64, f64, f64)
 -DEF_HELPER_1(float_FT, f32, i32)
 -DEF_HELPER_1(float_DT, f64, i32)
 -DEF_HELPER_3(fmac_FT, f32, f32, f32, f32)
 -DEF_HELPER_2(fmul_FT, f32, f32, f32)
 -DEF_HELPER_2(fmul_DT, f64, f64, f64)
 +DEF_HELPER_3(fcmp_eq_FT, void, env, f32, f32)
 +DEF_HELPER_3(fcmp_eq_DT, void, env, f64, f64)
 +DEF_HELPER_3(fcmp_gt_FT, void, env, f32, f32)
 +DEF_HELPER_3(fcmp_gt_DT, void, env, f64, f64)
 +DEF_HELPER_3(fdiv_FT, f32, env, f32, f32)
 +DEF_HELPER_3(fdiv_DT, f64, env, f64, f64)
 +DEF_HELPER_2(float_FT, f32, env, i32)
 +DEF_HELPER_2(float_DT, f64, env, i32)
 +DEF_HELPER_4(fmac_FT, f32, env, f32, f32, f32)
 +DEF_HELPER_3(fmul_FT, f32, env, f32, f32)
 +DEF_HELPER_3(fmul_DT, f64, env, f64, f64)
  DEF_HELPER_1(fneg_T, f32, f32)
 -DEF_HELPER_2(fsub_FT, f32, f32, f32)
 -DEF_HELPER_2(fsub_DT, f64, f64, f64)
 -DEF_HELPER_1(fsqrt_FT, f32, f32)
 -DEF_HELPER_1(fsqrt_DT, f64, f64)
 -DEF_HELPER_1(ftrc_FT, i32, f32)
 -DEF_HELPER_1(ftrc_DT, i32, f64)
 -DEF_HELPER_2(fipr, void, i32, i32)
 -DEF_HELPER_1(ftrv, void, i32)
 +DEF_HELPER_3(fsub_FT, f32, env, f32, f32)
 +DEF_HELPER_3(fsub_DT, f64, env, f64, f64)
 +DEF_HELPER_2(fsqrt_FT, f32, env, f32)
 +DEF_HELPER_2(fsqrt_DT, f64, env, f64)
 +DEF_HELPER_2(ftrc_FT, i32, env, f32)
 

Re: [Qemu-devel] [PATCH 16/21] target-arm: switch to AREG0 free mode

2012-09-02 Thread Peter Maydell
On 2 September 2012 18:33, Blue Swirl blauwir...@gmail.com wrote:
 Add an explicit CPUState parameter instead of relying on AREG0
 and switch to AREG0 free mode.

 Signed-off-by: Blue Swirl blauwir...@gmail.com
 ---
  configure|2 +-
  target-arm/Makefile.objs |2 -
  target-arm/cpu.h |   10 ++-
  target-arm/helper.c  |8 +-
  target-arm/helper.h  |   60 +-
  target-arm/op_helper.c   |   92 +---
  target-arm/translate.c   |  148 
 +++---
  7 files changed, 158 insertions(+), 164 deletions(-)

This is too big to easily review -- it's making a change to a lot
of helpers, and in each case that change affects three places
(callers, declaration, implementation). That'


 diff --git a/configure b/configure
 index 4fd3b7f..efb5014 100755
 --- a/configure
 +++ b/configure
 @@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
 $target_dir/Makefile


  case $target_arch2 in
 -  alpha | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | x86_64 | 
 xtensa* | ppc*)
 +  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
 x86_64 | xtensa* | ppc*)
  echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
;;
  esac
 diff --git a/target-arm/Makefile.objs b/target-arm/Makefile.objs
 index f447c4f..b6f1a9e 100644
 --- a/target-arm/Makefile.objs
 +++ b/target-arm/Makefile.objs
 @@ -2,5 +2,3 @@ obj-y += arm-semi.o
  obj-$(CONFIG_SOFTMMU) += machine.o
  obj-y += translate.o op_helper.o helper.o cpu.o
  obj-y += neon_helper.o iwmmxt_helper.o
 -
 -$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 diff --git a/target-arm/cpu.h b/target-arm/cpu.h
 index d7f93d9..7fac94f 100644
 --- a/target-arm/cpu.h
 +++ b/target-arm/cpu.h
 @@ -734,9 +734,10 @@ static inline void cpu_pc_from_tb(CPUARMState *env, 
 TranslationBlock *tb)
  }

  /* Load an instruction and return it in the standard little-endian order */
 -static inline uint32_t arm_ldl_code(uint32_t addr, bool do_swap)
 +static inline uint32_t arm_ldl_code(CPUARMState *env, uint32_t addr,
 +bool do_swap)
  {
 -uint32_t insn = ldl_code(addr);
 +uint32_t insn = cpu_ldl_code(env, addr);
  if (do_swap) {
  return bswap32(insn);
  }
 @@ -744,9 +745,10 @@ static inline uint32_t arm_ldl_code(uint32_t addr, bool 
 do_swap)
  }

  /* Ditto, for a halfword (Thumb) instruction */
 -static inline uint16_t arm_lduw_code(uint32_t addr, bool do_swap)
 +static inline uint16_t arm_lduw_code(CPUARMState *env, uint32_t addr,
 + bool do_swap)
  {
 -uint16_t insn = lduw_code(addr);
 +uint16_t insn = cpu_lduw_code(env, addr);
  if (do_swap) {
  return bswap16(insn);
  }
 diff --git a/target-arm/helper.c b/target-arm/helper.c
 index dceaa95..f4d711c 100644
 --- a/target-arm/helper.c
 +++ b/target-arm/helper.c
 @@ -1756,7 +1756,7 @@ static void do_interrupt_v7m(CPUARMState *env)
  case EXCP_BKPT:
  if (semihosting_enabled) {
  int nr;
 -nr = arm_lduw_code(env-regs[15], env-bswap_code)  0xff;
 +nr = arm_lduw_code(env, env-regs[15], env-bswap_code)  0xff;
  if (nr == 0xab) {
  env-regs[15] += 2;
  env-regs[0] = do_arm_semihosting(env);
 @@ -1828,9 +1828,9 @@ void do_interrupt(CPUARMState *env)
  if (semihosting_enabled) {
  /* Check for semihosting interrupt.  */
  if (env-thumb) {
 -mask = arm_lduw_code(env-regs[15] - 2, env-bswap_code)  
 0xff;
 +mask = arm_lduw_code(env, env-regs[15] - 2, 
 env-bswap_code)  0xff;
  } else {
 -mask = arm_ldl_code(env-regs[15] - 4, env-bswap_code)
 +mask = arm_ldl_code(env, env-regs[15] - 4, env-bswap_code)
   0xff;
  }
  /* Only intercept calls from privileged modes, to provide some
 @@ -1851,7 +1851,7 @@ void do_interrupt(CPUARMState *env)
  case EXCP_BKPT:
  /* See if this is a semihosting syscall.  */
  if (env-thumb  semihosting_enabled) {
 -mask = arm_lduw_code(env-regs[15], env-bswap_code)  0xff;
 +mask = arm_lduw_code(env, env-regs[15], env-bswap_code)  0xff;
  if (mask == 0xab
 (env-uncached_cpsr  CPSR_M) != ARM_CPU_MODE_USR) {
  env-regs[15] += 2;
 diff --git a/target-arm/helper.h b/target-arm/helper.h
 index 21e9cfe..afdb2b5 100644
 --- a/target-arm/helper.h
 +++ b/target-arm/helper.h
 @@ -4,12 +4,12 @@ DEF_HELPER_1(clz, i32, i32)
  DEF_HELPER_1(sxtb16, i32, i32)
  DEF_HELPER_1(uxtb16, i32, i32)

 -DEF_HELPER_2(add_setq, i32, i32, i32)
 -DEF_HELPER_2(add_saturate, i32, i32, i32)
 -DEF_HELPER_2(sub_saturate, i32, i32, i32)
 -DEF_HELPER_2(add_usaturate, i32, i32, i32)
 -DEF_HELPER_2(sub_usaturate, i32, i32, i32)
 -DEF_HELPER_1(double_saturate, i32, s32)
 

Re: [Qemu-devel] [PATCH 16/21] target-arm: switch to AREG0 free mode

2012-09-02 Thread Peter Maydell
On 3 September 2012 01:01, Peter Maydell peter.mayd...@linaro.org wrote:
 On 2 September 2012 18:33, Blue Swirl blauwir...@gmail.com wrote:
 Add an explicit CPUState parameter instead of relying on AREG0
 and switch to AREG0 free mode.

 Signed-off-by: Blue Swirl blauwir...@gmail.com
 ---
  configure|2 +-
  target-arm/Makefile.objs |2 -
  target-arm/cpu.h |   10 ++-
  target-arm/helper.c  |8 +-
  target-arm/helper.h  |   60 +-
  target-arm/op_helper.c   |   92 +---
  target-arm/translate.c   |  148 
 +++---
  7 files changed, 158 insertions(+), 164 deletions(-)

 This is too big to easily review -- it's making a change to a lot
 of helpers, and in each case that change affects three places
 (callers, declaration, implementation). That'

Sorry, finger slip meant I sent that half finished. To continue...

That's quite hard to cross-reference when the patch is this big.
I think it would be helpful if you could split it up into patches
touching smaller groups of helpers at once rather than having a
single patch that does them all at once.

thanks
-- PMM



[Qemu-devel] [PATCH v2] target-i386: Report on error during cpu_x86_register().

2012-09-02 Thread Don Slutz
Send it to stderr before free of the details.

Signed-off-by: Don Slutz d...@cloudswitch.com
---
v2: Change __FUNCTION__ to __func__

 target-i386/cpu.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 57c064f..760cca4 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1352,6 +1352,7 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
 }
 object_property_set_str(OBJECT(cpu), def-model_id, model-id, error);
 if (error_is_set(error)) {
+fprintf(stderr, %s: %s\n, __func__, error_get_pretty(error));
 error_free(error);
 return -1;
 }
-- 
1.7.1




[Qemu-devel] [PATCH] cpu_physical_memory_write_rom() needs to do TB invalidates

2012-09-02 Thread David Gibson
cpu_physical_memory_write_rom(), despite the name, can also be used to
write images into RAM - and will often be used that way if the machine
uses load_image_targphys() into RAM addresses.

However, cpu_physical_memory_write_rom(), unlike
cpu_physical_memory_rw() doesn't invalidate any cached TBs which might
be affected by the region written.

This was breaking reset (under full emu) on the pseries machine - we loaded
our firmware image into RAM, and while executing it rewrite the code at
the entry point (correctly causing a TB invalidate/refresh).  When we
reset the firmware image was reloaded, but the TB from the rewrite was
still active and caused us to get an illegal instruction trap.

This patch fixes the bug by duplicating the tb invalidate code from
cpu_physical_memory_rw() in cpu_physical_memory_write_rom().

Signed-off-by: David Gibson da...@gibson.dropbear.id.au
---
 exec.c |7 +++
 1 file changed, 7 insertions(+)

I've sent this before, and there was some discussion about the
details, but as far as I can tell the conclusion was that this patch
was as good as any, at least for fixing the existing bug in 1.2 /
stable.  However, it still hasn't been merged.

Please apply for stable as well as mainline.

diff --git a/exec.c b/exec.c
index 5834766..eff40d7 100644
--- a/exec.c
+++ b/exec.c
@@ -3523,6 +3523,13 @@ void cpu_physical_memory_write_rom(target_phys_addr_t 
addr,
 /* ROM/RAM case */
 ptr = qemu_get_ram_ptr(addr1);
 memcpy(ptr, buf, l);
+if (!cpu_physical_memory_is_dirty(addr1)) {
+/* invalidate code */
+tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
+/* set dirty bit */
+cpu_physical_memory_set_dirty_flags(
+addr1, (0xff  ~CODE_DIRTY_FLAG));
+}
 qemu_put_ram_ptr(ptr);
 }
 len -= l;
-- 
1.7.10.4




Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Sun, Sep 2, 2012 at 10:45 PM, Alexander Graf ag...@suse.de wrote:


 On 02.09.2012, at 09:50, Li Zhang zhlci...@gmail.com wrote:

 On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl blauwir...@gmail.com wrote:
 On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf ag...@suse.de wrote:


 On 26.08.2012, at 10:34, Blue Swirl blauwir...@gmail.com wrote:

 On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf ag...@suse.de wrote:


 On 25.08.2012, at 00:43, Blue Swirl blauwir...@gmail.com wrote:

 On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang zhlci...@gmail.com wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.

 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.

 USB option of machine options will be set either by:
 * -usb
 * -machine type=pseries,usb=on

 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
 v7-v8 :
 * Declare usb_enabled() and set_usb_option() in sysemu.h
 * Separate USB enablement on sPAPR platform.

 v8-v9:
 * Fix usb_enable() default value on sPAPR and MAC99

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com

 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
 char *boot_device,
   n8x0_dss_setup(s);
   n8x0_cbus_setup(s);
   n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))

 Please add braces.

 I don't like this usb_enabled(false) way very much but I don't have
 anything better to suggest.

   n8x0_usb_setup(s);

   if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
   pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
floppy, idebus[0], idebus[1], rtc_state);

 -if (pci_enabled  usb_enabled) {
 +if (pci_enabled  usb_enabled(false)) {
   pci_create_simple(pci_bus, piix3_devfn + 2, piix3-usb-uhci);
   }

 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
   ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
   ide_mem[2] = pmac_ide_init(hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 
 0x1a, pic[0x02]);

 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
   cuda_init(cuda_mem, pic[0x19]);

   adb_kbd_init(adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
  dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create(keyboard);
 -usbdevice_create(mouse);
 +/* U3 needs to use USB for input because Linux doesn't 
 support via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create(keyboard);
 +usbdevice_create(mouse);
 +}
   }

   if (graphic_depth != 15  graphic_depth != 32  graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
  dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
   }

 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
 index 7a87616..feeb903 100644
 --- a/hw/ppc_prep.c
 +++ b/hw/ppc_prep.c
 @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
   memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   pci_create_simple(pci_bus, -1, pci-ohci);
   }

 diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
 index d5f1420..4787279 100644
 --- a/hw/pxa2xx.c
 +++ b/hw/pxa2xx.c
 @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion 
 *address_space,
   s-ssp[i] = (SSIBus *)qdev_get_child_bus(dev, ssi);
   }

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   sysbus_create_simple(sysbus-ohci, 0x4c00,
  

[Qemu-devel] [PATCH v4 0/5] Running Microport UNIX (ca 1987)

2012-09-02 Thread Matthew Ogilvie
This series is fixing issues I found when getting qemu to run
Micoport UNIX System V/386, v 2.1 (ca 1987), although most of
the patches are completely independent of each other.

Changes since v2 and v3:

   - Drop the -no-spurious-interrupts patch.  (It might still be useful
 as an end-user workaround for other potential interrupt bugs, but I'm
 not going to push for it.)

   - Add a completely new patch to fix for how the master i8259
 handles IRQ2 when the original interrupt (say IRQ14) is
 dynamically masked off in the slave via the IMR register.
 This is supported by a test program I wrote.  There are probably
 some tweaks still desired (KVM at least), but I'm fairly
 confident this basic approach is correct.

   - Squash in the remaining two small v3 incremental patches into v2.

   - [applied] The mov to/from crN/drN patch has been applied (and not
 reverted), and is no longer included with this series.


Matthew Ogilvie (5):
  fix some debug printf format strings
  vl: fix -hdachs/-hda argument order parsing issues
  qemu-options.hx: mention retrace= VGA option
  vga: add some optional CGA compatibility hacks
  i8259: fix dynamically masking slave IRQs with IMR register

 hw/cirrus_vga.c |  4 ++--
 hw/i8259.c  | 15 -
 hw/i8259_common.c   |  2 ++
 hw/i8259_internal.h |  1 +
 hw/ide/cmd646.c |  5 +++--
 hw/ide/via.c|  5 +++--
 hw/pc.h |  4 
 hw/vga.c| 37 +---
 qemu-options.hx | 27 ++-
 vl.c| 62 +++--
 10 files changed, 121 insertions(+), 41 deletions(-)

-- 
1.7.10.2.484.gcd07cc5




[Qemu-devel] [PATCH v4 2/5] vl: fix -hdachs/-hda argument order parsing issues

2012-09-02 Thread Matthew Ogilvie
Without this patch, the -hdachs argument had to occur either
BEFORE the corresponding -hda option, or AFTER the plain
disk image name (if neither -hda nor -drive is used).  Otherwise
it would effectively be ignored.

Option -hdachs still has no effect on -drive, but that seems best.

Signed-off-by: Matthew Ogilvie mmogilvi_q...@miniinfo.net
---
 vl.c | 39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/vl.c b/vl.c
index 7c577fa..febfd62 100644
--- a/vl.c
+++ b/vl.c
@@ -2352,8 +2352,9 @@ int main(int argc, char **argv, char **envp)
 char boot_devices[33] = cad; /* default to HD-floppy-CD-ROM */
 DisplayState *ds;
 DisplayChangeListener *dcl;
-int cyls, heads, secs, translation;
-QemuOpts *hda_opts = NULL, *opts, *machine_opts;
+char hdachs_params[512];  /* save -hdachs to apply to later -hda */
+QemuOpts *hda_opts = NULL; /* save -hda to be modified by later -hdachs */
+QemuOpts *opts, *machine_opts;
 QemuOptsList *olist;
 int optind;
 const char *optarg;
@@ -2408,8 +2409,7 @@ int main(int argc, char **argv, char **envp)
 cpu_model = NULL;
 ram_size = 0;
 snapshot = 0;
-cyls = heads = secs = 0;
-translation = BIOS_ATA_TRANSLATION_AUTO;
+snprintf(hdachs_params, sizeof(hdachs_params), %s, HD_OPTS);
 
 for (i = 0; i  MAX_NODES; i++) {
 node_mem[i] = 0;
@@ -2457,7 +2457,7 @@ int main(int argc, char **argv, char **envp)
 if (optind = argc)
 break;
 if (argv[optind][0] != '-') {
-   hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
+hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], hdachs_params);
 } else {
 const QEMUOption *popt;
 
@@ -2475,21 +2475,8 @@ int main(int argc, char **argv, char **envp)
 cpu_model = optarg;
 break;
 case QEMU_OPTION_hda:
-{
-char buf[256];
-if (cyls == 0)
-snprintf(buf, sizeof(buf), %s, HD_OPTS);
-else
-snprintf(buf, sizeof(buf),
- %s,cyls=%d,heads=%d,secs=%d%s,
- HD_OPTS , cyls, heads, secs,
- translation == BIOS_ATA_TRANSLATION_LBA ?
- ,trans=lba :
- translation == BIOS_ATA_TRANSLATION_NONE ?
- ,trans=none : );
-drive_add(IF_DEFAULT, 0, optarg, buf);
-break;
-}
+hda_opts = drive_add(IF_DEFAULT, 0, optarg, hdachs_params);
+break;
 case QEMU_OPTION_hdb:
 case QEMU_OPTION_hdc:
 case QEMU_OPTION_hdd:
@@ -2523,7 +2510,10 @@ int main(int argc, char **argv, char **envp)
 break;
 case QEMU_OPTION_hdachs:
 {
+int cyls, heads, secs, translation;
 const char *p;
+cyls = heads = secs = 0;
+translation = BIOS_ATA_TRANSLATION_AUTO;
 p = optarg;
 cyls = strtol(p, (char **)p, 0);
 if (cyls  1 || cyls  16383)
@@ -2555,7 +2545,14 @@ int main(int argc, char **argv, char **envp)
 fprintf(stderr, qemu: invalid physical CHS format\n);
 exit(1);
 }
-   if (hda_opts != NULL) {
+snprintf(hdachs_params, sizeof(hdachs_params),
+ %s,cyls=%d,heads=%d,secs=%d%s,
+ HD_OPTS , cyls, heads, secs,
+ translation == BIOS_ATA_TRANSLATION_LBA ?
+ ,trans=lba :
+ translation == BIOS_ATA_TRANSLATION_NONE ?
+ ,trans=none : );
+if (hda_opts != NULL) {
 char num[16];
 snprintf(num, sizeof(num), %d, cyls);
 qemu_opt_set(hda_opts, cyls, num);
-- 
1.7.10.2.484.gcd07cc5




[Qemu-devel] [PATCH v4 1/5] fix some debug printf format strings

2012-09-02 Thread Matthew Ogilvie
These are normally ifdefed out and don't matter.  But if you enable
them, they ought to be correct.

Signed-off-by: Matthew Ogilvie mmogilvi_q...@miniinfo.net
---

Changes since v2: The v3 tweak (adding back a dropped 02) has been
squashed in.

 hw/cirrus_vga.c | 4 ++--
 hw/i8259.c  | 3 ++-
 hw/ide/cmd646.c | 5 +++--
 hw/ide/via.c| 5 +++--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index e8dcc6b..68c36f3 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2055,8 +2055,8 @@ static void cirrus_vga_mem_write(void *opaque,
}
 } else {
 #ifdef DEBUG_CIRRUS
-printf(cirrus: mem_writeb  TARGET_FMT_plx  value %02x\n, addr,
-   mem_value);
+printf(cirrus: mem_writeb  TARGET_FMT_plx  value %02 PRIx64 \n,
+   addr, mem_value);
 #endif
 }
 }
diff --git a/hw/i8259.c b/hw/i8259.c
index 53daf78..6587666 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -355,7 +355,8 @@ static uint64_t pic_ioport_read(void *opaque, 
target_phys_addr_t addr,
 ret = s-imr;
 }
 }
-DPRINTF(read: addr=0x%02x val=0x%02x\n, addr, ret);
+DPRINTF(read: addr=0x%02 TARGET_PRIxPHYS  val=0x%02x\n,
+addr, ret);
 return ret;
 }
 
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index e0b9443..dd2855e 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -154,7 +154,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t 
addr,
 break;
 }
 #ifdef DEBUG_IDE
-printf(bmdma: readb 0x%02x : 0x%02x\n, addr, val);
+printf(bmdma: readb 0x%02 TARGET_PRIxPHYS  : 0x%02x\n, addr, val);
 #endif
 return val;
 }
@@ -170,7 +170,8 @@ static void bmdma_write(void *opaque, target_phys_addr_t 
addr,
 }
 
 #ifdef DEBUG_IDE
-printf(bmdma: writeb 0x%02x : 0x%02x\n, addr, val);
+printf(bmdma: writeb 0x%02 TARGET_PRIxPHYS  : 0x%02 PRIx64 \n,
+   addr, val);
 #endif
 switch(addr  3) {
 case 0:
diff --git a/hw/ide/via.c b/hw/ide/via.c
index b20e4f0..948a469 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -55,7 +55,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t 
addr,
 break;
 }
 #ifdef DEBUG_IDE
-printf(bmdma: readb 0x%02x : 0x%02x\n, addr, val);
+printf(bmdma: readb 0x%02 TARGET_PRIxPHYS  : 0x%02x\n, addr, val);
 #endif
 return val;
 }
@@ -70,7 +70,8 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr,
 }
 
 #ifdef DEBUG_IDE
-printf(bmdma: writeb 0x%02x : 0x%02x\n, addr, val);
+printf(bmdma: writeb 0x%02 TARGET_PRIxPHYS  : 0x%02 PRIx64 \n,
+   addr, val);
 #endif
 switch (addr  3) {
 case 0:
-- 
1.7.10.2.484.gcd07cc5




[Qemu-devel] [PATCH v4 4/5] vga: add some optional CGA compatibility hacks

2012-09-02 Thread Matthew Ogilvie
This patch adds some optional compatibility hacks (default
disabled) to allow Microport UNIX to function under qemu.

I've tried to structure it to be easy to add more hacks for other
old CGA programs, if anyone ever needs them.

Microport UNIX System V/386 v 2.1 (ca 1987) tries to program
the CGA registers directly with neither the assistance of BIOS, nor
with proper handling of EGA/VGA-only registers.  Note that it didn't
work on real VGA hardware, either (although in that case, the most
obvious problems seemed to be out-of-range hsync and/or vsync
signalling, rather than the issues in this patch).

Eventually real MDA and/or CGA support might provide an alternative to
this patch, although a hybrid approach like this patch might still
be useful in marginal cases.

Signed-off-by: Matthew Ogilvie mmogilvi_q...@miniinfo.net
---

Change since v2: The v3 tweak (fix conditions for palette blanking hack)
has been squashed in.

 hw/pc.h |  4 
 hw/vga.c| 37 +
 qemu-options.hx | 19 +++
 vl.c| 23 +++
 4 files changed, 75 insertions(+), 8 deletions(-)

diff --git a/hw/pc.h b/hw/pc.h
index e4db071..37e2f87 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -176,6 +176,10 @@ enum vga_retrace_method {
 
 extern enum vga_retrace_method vga_retrace_method;
 
+#define VGA_CGA_HACK_PALETTE_BLANKING  (10)
+#define VGA_CGA_HACK_FONT_HEIGHT   (11)
+extern int vga_cga_hacks;
+
 static inline DeviceState *isa_vga_init(ISABus *bus)
 {
 ISADevice *dev;
diff --git a/hw/vga.c b/hw/vga.c
index f82ced8..fb08dc0 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -547,14 +547,31 @@ void vga_ioport_write(void *opaque, uint32_t addr, 
uint32_t val)
 printf(vga: write CR%x = 0x%02x\n, s-cr_index, val);
 #endif
 /* handle CR0-7 protection */
-if ((s-cr[VGA_CRTC_V_SYNC_END]  VGA_CR11_LOCK_CR0_CR7) 
-s-cr_index = VGA_CRTC_OVERFLOW) {
-/* can always write bit 4 of CR7 */
-if (s-cr_index == VGA_CRTC_OVERFLOW) {
-s-cr[VGA_CRTC_OVERFLOW] = (s-cr[VGA_CRTC_OVERFLOW]  ~0x10) |
-(val  0x10);
+if (s-cr[VGA_CRTC_V_SYNC_END]  VGA_CR11_LOCK_CR0_CR7) {
+if (s-cr_index = VGA_CRTC_OVERFLOW) {
+/* can always write bit 4 of CR7 */
+if (s-cr_index == VGA_CRTC_OVERFLOW) {
+s-cr[VGA_CRTC_OVERFLOW] =
+(s-cr[VGA_CRTC_OVERFLOW]  ~0x10) | (val  0x10);
+}
+return;
+} else if ((vga_cga_hacks  VGA_CGA_HACK_FONT_HEIGHT) 
+   !(s-sr[VGA_SEQ_CLOCK_MODE]  VGA_SR01_CHAR_CLK_8DOTS)) 
{
+/* extra CGA compatibility hacks (not in standard VGA) */
+if (s-cr_index == VGA_CRTC_MAX_SCAN 
+val == 7 
+(s-cr[VGA_CRTC_MAX_SCAN]  0xf) == 0xf) {
+return;
+} else if (s-cr_index == VGA_CRTC_CURSOR_START 
+   val == 6 
+   (s-cr[VGA_CRTC_MAX_SCAN]  0xf) == 0xf) {
+val = 0xd;
+} else if (s-cr_index == VGA_CRTC_CURSOR_END 
+   val == 7 
+   (s-cr[VGA_CRTC_MAX_SCAN]  0xf) == 0xf) {
+val = 0xe;
+}
 }
-return;
 }
 s-cr[s-cr_index] = val;
 
@@ -1886,7 +1903,11 @@ static void vga_update_display(void *opaque)
 /* nothing to do */
 } else {
 full_update = 0;
-if (!(s-ar_index  0x20)) {
+if (!(s-ar_index  0x20) 
+/* extra CGA compatibility hacks (not in standard VGA) */
+(!(vga_cga_hacks  VGA_CGA_HACK_PALETTE_BLANKING) ||
+ s-ar_index != 0 ||
+ !s-ar_flip_flop)) {
 graphic_mode = GMODE_BLANK;
 } else {
 graphic_mode = s-gr[VGA_GFX_MISC]  VGA_GR06_GRAPHICS_MODE;
diff --git a/qemu-options.hx b/qemu-options.hx
index 3e8085d..68925f3 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -975,6 +975,25 @@ Valid optional properties are
 @item retrace=dumb|precise
 Select dumb (default) or precise VGA retrace logic, useful for some
 DOS games/demos.
+@item cga_hacks=@var{hack1}[+@var{hack2}[+...]]
+Enable various extra CGA compatibility hacks for programs that are
+trying to directly set CGA modes without BIOS assistance nor
+real knowledge of EGA/VGA.  These might only work with -vga std.
+Valid hacks are
+@table @option
+@item palette_blanking
+Wait to blank the screen until palette registers seem to actually be
+modified, instead of blanking it as soon as the palette address bit (0x10)
+of the attribute address register (0x3c0) is cleared.
+@item font_height
+Ignore attempts to change the VGA font height (index 9),
+cursor start (index 10), and cursor end (index 11) of the CRTC control
+registers (0x3d5) if trying to set them to the default 

[Qemu-devel] [PATCH v4 3/5] qemu-options.hx: mention retrace= VGA option

2012-09-02 Thread Matthew Ogilvie
The feature was added in commit cb5a7aa8c32141bb Sep 2008.
My description is based on Better VGA retrace emulation (needed
for some DOS games/demos) from
http://www.boblycat.org/~malc/code/patches/qemu/index.html

Signed-off-by: Matthew Ogilvie mmogilvi_q...@miniinfo.net
---
 qemu-options.hx | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 3c411c4..3e8085d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -945,7 +945,7 @@ DEF(vga, HAS_ARG, QEMU_OPTION_vga,
 -vga [std|cirrus|vmware|qxl|xenfb|none]\n
 select video card type\n, QEMU_ARCH_ALL)
 STEXI
-@item -vga @var{type}
+@item -vga @var{type}[,@var{prop}=@var{value}[,...]]
 @findex -vga
 Select type of VGA card to emulate. Valid values for @var{type} are
 @table @option
@@ -970,6 +970,12 @@ Recommended choice when using the spice protocol.
 @item none
 Disable VGA card.
 @end table
+Valid optional properties are
+@table @option
+@item retrace=dumb|precise
+Select dumb (default) or precise VGA retrace logic, useful for some
+DOS games/demos.
+@end table
 ETEXI
 
 DEF(full-screen, 0, QEMU_OPTION_full_screen,
-- 
1.7.10.2.484.gcd07cc5




[Qemu-devel] [PATCH v4 5/5] i8259: fix dynamically masking slave IRQs with IMR register

2012-09-02 Thread Matthew Ogilvie
Although I haven't found any specs that say so, on real hardware
I have a test program that shows if you mask off the slave
interrupt (say IRQ14) in the IMR after it has already been raised,
the master (IRQ2) gets canceled (that is, IRQ2 acts like it is level
triggered).  Without this patch, qemu delivers a
spurious interrupt (IRQ15) instead when running the test program.

Signed-off-by: Matthew Ogilvie mmogilvi_q...@miniinfo.net
---

I've written a test program (in the form of a floppy disk boot sector)
that demonstrates that qemu's emulation of IRQ2 propagation from the
slave i8259 to the master does not work correctly when the CPU has
interrupts disabled and it masks off the original interrupt (IRQ14)
in the slave's IMR register.  This was based on simplifying breakage
observed when trying to run an old Microport UNIX system (ca 1987).

Earlier I speculated that maybe the ELCR bit for IRQ2 was incorrect,
but now I don't think changing the bit (from the target's
perspective) would be a good idea.  See below.

You can download the source code for the test program from
http://home.comcast.net/~mmogilvi/downloads/i8259-imr-test-2012-09-02.tar.bz2
It can be compiled using a standard GNU i386 toolchain on Linux.

The heart of the test program is:

cli

  # i8259:imm: mask off everything except IRQ2
movb $0xfb,%al # master (only IRQ2 clear)
outb %al,$0x21
movb $0xff,%al # slave
outb %al,$0xa1

mov $.msgCmdRead,%ax
call print
call initIrqHandlers
call scheduleIrq14

call .largeDelay   # note: IRQ14 raised while this is waiting

mov $.msgUnmask,%ax
call print
movb $0x3f,%al # unmask IRQ14 and IRQ15
outb %al,$0xa1

call .largeDelay   # (probably not important)

mov $.msgMask,%ax
call print
movb $0xff,%al # mask IRQ14 and IRQ15 again
outb %al,$0xa1

call .largeDelay   # (probably not important)

mov $.msgSti,%ax
call print
sti

call .largeDelay   # note: spurious interrupt (IRQ15) from qemu

cli
mov $.msgUnmask,%ax
call print
movb $0x3f,%al # unmask IRQ14 and IRQ15
outb %al,$0xa1
sti

call .largeDelay   # we should finally see IRQ14 here?

  # DONE:
cli
movw $.msgDone, %ax
call print
  .Lhalt:
hlt
jmp .Lhalt

In qemu, the master treats IRQ2 as edge triggered, and delivers a
spurious interrupt if the CPU re-enables interrupts after
the slave's IMR is masked off (it also doesn't seem to deliver
the real interrupt when the IMR is unmasked, but maybe that is
because I'm not correctly acknowledging the spurious interrupt).

  - Qemu output (without this patch):
elcr=0c00 cmdRead ummask mask sti irq15 unmask DONE

But on real hardware, the master seems to treat IRQ2 as level triggered,
and doesn't deliver an interrupt to the CPU until the slave unmasks IRQ14.
I've tried this on several machines, including a non-PCI 486 that
does not seem to have ELCR registers.

  - Typical output (pentium/pentium pro/dual AMD Athlon/etc; slight
variations in some elcr bits depending on machine, but bit 0x04
is always clear):
elcr=0c20 cmdRead unmask mask sti unmask irq14 DONE

  - 486 without elcr (just an ISA bus):
elcr=e0e0 cmdRead unmask mask sti unmask irq14 DONE

  - One failure: It doesn't boot properly (no output) with a USB floppy
drive on my Intel Core I7.  Guess: The test program just barely
fits in a sector, with no room for any tables (partition/etc)
that BIOS might check for if it isn't an original, native floppy
drive.

---

I've found a few descriptions of programming the i8259.
The closest thing I've found to a detailed spec is in
iAPX 86, 88 User's Manual, dated August 1981:
http://ebookbrowse.com/1981-iapx-86-88-users-manual-pdf-d3089962
It has a significant section titled Using the 8259A Programmable
Interrupt Controller starting on page 438 or A-135.

But none of my sources seem to specify how master/slave cascading
interacts with the IMR (mask register) and edge trigger mode,
although it talks about those things individually.
Also, given the date it isn't surprising that it doesn't mention
the elcr registers at all.

I have not found any real specs for the ELCR registers, but I've found a
few hints:

  - Two 8 bit registers: one for master (0x4d0) and one for slave (0x4d1).
  - One bit per IRQ line: 0 for edge trigger, 1 for level trigger.
  - Not present unless the machine has EISA or PCI buses.  Plain
ISA doesn't have it.
  - Might be implemented completely external to the actual i8259s.
  - As seen in test program output above, ELCR bit 0x04 is clear,
indicating that IRQ2 is supposedly edge triggered, even though
actual tested behavior is level triggered.
  - A google search (8259 elcr -linux -qemu) [exclude the
   

[Qemu-devel] [PATCH-v2 spice-protocol 1/2] Add A8 surface capability

2012-09-02 Thread Søren Sandmann Pedersen
Even though the ability to handle a8 surfaces was added at the same
time as the composite command, they are logically separate, so add a
capability bit to indicate the presence of a8 surfaces.
---
 spice/protocol.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spice/protocol.h b/spice/protocol.h
index 7008399..0671292 100644
--- a/spice/protocol.h
+++ b/spice/protocol.h
@@ -128,6 +128,7 @@ enum {
 SPICE_DISPLAY_CAP_SIZED_STREAM,
 SPICE_DISPLAY_CAP_MONITORS_CONFIG,
 SPICE_DISPLAY_CAP_COMPOSITE,
+SPICE_DISPLAY_CAP_A8_SURFACE,
 };
 
 enum {
-- 
1.7.11.4




[Qemu-devel] New patches to add capabilities to spice and qxl

2012-09-02 Thread Søren Sandmann Pedersen
Hi,

Here are new revisions of the capabilities patches. Also included here
is a new SPICE_DISPLAY_CAP_A8_SURFACE capability since this is
logically distinct from the composite command.

Thanks,
Soren




[Qemu-devel] [PATCH-v2 spice-gtk] Advertise SPICE_DISPLAY_CAP_A8_SURFACE

2012-09-02 Thread Søren Sandmann Pedersen
---
 gtk/channel-display.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 99fe9c9..326ad22 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -682,6 +682,7 @@ static void 
spice_display_channel_reset_capabilities(SpiceChannel *channel)
 spice_channel_set_capability(SPICE_CHANNEL(channel), 
SPICE_DISPLAY_CAP_SIZED_STREAM);
 spice_channel_set_capability(SPICE_CHANNEL(channel), 
SPICE_DISPLAY_CAP_MONITORS_CONFIG);
 spice_channel_set_capability(SPICE_CHANNEL(channel), 
SPICE_DISPLAY_CAP_COMPOSITE);
+spice_channel_set_capability(SPICE_CHANNEL(channel), 
SPICE_DISPLAY_CAP_A8_SURFACE);
 }
 
 static void spice_display_channel_init(SpiceDisplayChannel *channel)
-- 
1.7.11.4




[Qemu-devel] [PATCH-v2 qemu] qxl: Add set_client_capabilities() interface to QXLInterface

2012-09-02 Thread Søren Sandmann Pedersen
This new interface lets spice server inform the guest whether

(a) a client is connected
(b) what capabilities the client has

There is a fixed number (464) of bits reserved for capabilities, and
when the capabilities bits change, the QXL_INTERRUPT_CLIENT interrupt
is generated.

Signed-off-by: Soren Sandmann s...@redhat.com
---
 hw/qxl.c | 29 -
 hw/qxl.h |  2 +-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index c2dd3b4..1f62529 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -901,6 +901,26 @@ static void interface_async_complete(QXLInstance *sin, 
uint64_t cookie_token)
 }
 }
 
+#if SPICE_SERVER_VERSION = 0x000b04
+
+/* called from spice server thread context only */
+static void interface_set_client_capabilities(QXLInstance *sin,
+ uint8_t client_present,
+ uint8_t caps[58])
+{
+PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
+
+qxl-shadow_rom.client_present = client_present;
+memcpy(qxl-shadow_rom.client_capabilities, caps, sizeof(caps));
+qxl-rom-client_present = client_present;
+memcpy(qxl-rom-client_capabilities, caps, sizeof(caps));
+qxl_rom_set_dirty(qxl);
+
+qxl_send_events(qxl, QXL_INTERRUPT_CLIENT);
+}
+
+#endif
+
 static const QXLInterface qxl_interface = {
 .base.type   = SPICE_INTERFACE_QXL,
 .base.description= qxl gpu,
@@ -922,6 +942,9 @@ static const QXLInterface qxl_interface = {
 .flush_resources = interface_flush_resources,
 .async_complete  = interface_async_complete,
 .update_area_complete= interface_update_area_complete,
+#if SPICE_SERVER_VERSION = 0x000b04
+.set_client_capabilities = interface_set_client_capabilities,
+#endif
 };
 
 static void qxl_enter_vga_mode(PCIQXLDevice *d)
@@ -1292,7 +1315,7 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr, int 
loadvm)
 
 d-mode = QXL_MODE_COMPAT;
 d-cmdflags = QXL_COMMAND_FLAG_COMPAT;
-#ifdef QXL_COMMAND_FLAG_COMPAT_16BPP /* new in spice 0.6.1 */
+#if QXL_COMMAND_FLAG_COMPAT_16BPP /* new in spice 0.6.1 */
 if (mode-bits == 16) {
 d-cmdflags |= QXL_COMMAND_FLAG_COMPAT_16BPP;
 }
@@ -1785,6 +1808,10 @@ static int qxl_init_common(PCIQXLDevice *qxl)
 io_size = 16;
 break;
 case 3: /* qxl-3 */
+   pci_device_rev = QXL_REVISION_STABLE_V10;
+   io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
+   break;
+case 4:
 default:
 pci_device_rev = QXL_DEFAULT_REVISION;
 io_size = msb_mask(QXL_IO_RANGE_SIZE * 2 - 1);
diff --git a/hw/qxl.h b/hw/qxl.h
index 172baf6..98d5a64 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -128,7 +128,7 @@ typedef struct PCIQXLDevice {
 }   \
 } while (0)
 
-#define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V10
+#define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V12
 
 /* qxl.c */
 void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
-- 
1.7.11.4




[Qemu-devel] [PATCH-v2 spice 2/2] Bump spice.h version number to 0.11.4

2012-09-02 Thread Søren Sandmann Pedersen
No new symbols are added, but there is an addition to QXLInterface:

void (*set_client_capabilities)(QXLInstance *qin,
uint8_t client_present,
uint8_t caps[58]);
---
 server/spice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/spice.h b/server/spice.h
index 9d65efa..71adfb6 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -22,7 +22,7 @@
 #include sys/socket.h
 #include spice/qxl_dev.h
 
-#define SPICE_SERVER_VERSION 0x000b02 /* release 0.11.2 */
+#define SPICE_SERVER_VERSION 0x000b04 /* release 0.11.4 */
 
 /* interface base type */
 
-- 
1.7.11.4




[Qemu-devel] [PATCH-v2 spice-protocol 2/2] Add new client_present and client capabilities fields to QXLRom

2012-09-02 Thread Søren Sandmann Pedersen
The client_present field is a byte that is set of non-zero when a
client is connected and to zero when no client is connected.

The client_capabilities[58] array contains 464 bits that indicate the
capabilities of the client. Each bit corresponds to a
SPICE_DISPLAY_CAP_* capability. In particular, if the client has
capability C, then bit (C % 8) in byte (C / 8) is set. The capability
bits only have a defined meaning when a client is connected, ie., when
client_present is non-zero. The number 58 was chosen to fill out a
cache line in QXLRom.

A new QXL_INTERRUPT_CLIENT interrupt is defined, which will be raised
whenever a client connects or disconnects.
---
 spice/qxl_dev.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
index 1292767..50784dc 100644
--- a/spice/qxl_dev.h
+++ b/spice/qxl_dev.h
@@ -148,7 +148,9 @@ typedef struct SPICE_ATTR_PACKED QXLRom {
 uint8_t slot_gen_bits;
 uint8_t slot_id_bits;
 uint8_t slot_generation;
-uint8_t padding[3]; /* Padding to 32bit align */
+/* appended for qxl-4 */
+uint8_t client_present;
+uint8_t client_capabilities[58];
 } QXLRom;
 
 /* qxl-1 compat: fixed */
@@ -231,6 +233,7 @@ SPICE_RING_DECLARE(QXLReleaseRing, uint64_t, 
QXL_RELEASE_RING_SIZE);
 #define QXL_INTERRUPT_CURSOR (1  1)
 #define QXL_INTERRUPT_IO_CMD (1  2)
 #define QXL_INTERRUPT_ERROR  (1  3)
+#define QXL_INTERRUPT_CLIENT (1  4)
 
 /* qxl-1 compat: append only */
 typedef struct SPICE_ATTR_PACKED QXLRam {
-- 
1.7.11.4




Re: [Qemu-devel] Detecting context switch in QEMU

2012-09-02 Thread Mulyadi Santosa
Hi Xin Tong..

On Mon, Sep 3, 2012 at 4:48 AM, Xin Tong xerox.time.t...@gmail.com wrote:
 BTW, if a thread makes a system call, when the kernel is servicing the
 syscall. is it still accessing the thread's memory using the threads
 page table (i.e. the kernel is using virtual address ?). how about AIO
 kernel threads  ?

accessing thread user space memory? hmquite likely... let's say in
a case of read() or write()

AIO kernel thread... not sure, I guess eventually kernel AIO thread
will wake up the user space side and do some data transfer from kernel
to user space (or maybe also the other way around).

The word async here stress the meaning that the kernel side of I/O
operation doesn't operate in the context of the reading/writing
process. CMIIW

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



[Qemu-devel] [PATCH-v2 spice 1/2] Set a8 capability in the QXL device if supported by the client

2012-09-02 Thread Søren Sandmann Pedersen
---
 server/red_worker.c | 2 ++
 spice-common| 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 843f559..23f3464 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -10377,6 +10377,8 @@ static void handle_new_display_channel(RedWorker 
*worker, RedClient *client, Red
 SET_CAP(caps, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
 if (red_channel_client_test_remote_cap(rcc, 
SPICE_DISPLAY_CAP_COMPOSITE))
 SET_CAP(caps, SPICE_DISPLAY_CAP_COMPOSITE);
+if (red_channel_client_test_remote_cap(rcc, 
SPICE_DISPLAY_CAP_COMPOSITE))
+SET_CAP(caps, SPICE_DISPLAY_CAP_A8_SURFACE);
 
 worker-qxl-st-qif-set_client_capabilities(worker-qxl, TRUE, caps);
 }
diff --git a/spice-common b/spice-common
index 86e286b..04dc2be 16
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 86e286ba2003c206e700fd70ec67c1cf4ac8d8a6
+Subproject commit 04dc2bee9ecdda7d7966f9267df37ab23bb5a802
-- 
1.7.11.4




[Qemu-devel] [Qemu-ppc][PATCH v10 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
When -usb option is used, global varible usb_enabled is set.
And all the plaform will create one USB controller according
to this variable. In fact, global varibles make code hard
to read.

So this patch is to remove global variable usb_enabled and
add USB option in machine options. All the plaforms will get
USB option value from machine options.

USB option of machine options will be set either by:
  * -usb
  * -machine type=pseries,usb=on

Both these ways can work now. They both set USB option in
machine options. In the future, the first way will be removed.

Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
---
 v7 - v8 :
  * Declare usb_enabled() and set_usb_option() in sysemu.h
  * Separate USB enablement on sPAPR platform.

 v8 - v9:
  * Fix usb_enable() default value on sPAPR and MAC99

 v9 - v10:
  * remove set_usb_option()
  * Fix one place of coding style.

 hw/nseries.c  |3 ++-
 hw/pc_piix.c  |2 +-
 hw/ppc_newworld.c |   19 +++
 hw/ppc_oldworld.c |2 +-
 hw/ppc_prep.c |2 +-
 hw/pxa2xx.c   |4 ++--
 hw/realview.c |2 +-
 hw/spapr.c|2 +-
 hw/versatilepb.c  |2 +-
 qemu-config.c |4 
 sysemu.h  |4 +++-
 vl.c  |   30 --
 12 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/hw/nseries.c b/hw/nseries.c
index 4df2670..a96c9b1 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1322,8 +1322,9 @@ static void n8x0_init(ram_addr_t ram_size, const char 
*boot_device,
 n8x0_dss_setup(s);
 n8x0_cbus_setup(s);
 n8x0_uart_setup(s);
-if (usb_enabled)
+if (usb_enabled(false)) {
 n8x0_usb_setup(s);
+}
 
 if (kernel_filename) {
 /* Or at the linux loader.  */
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 88ff041..b603fab 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
  floppy, idebus[0], idebus[1], rtc_state);
 
-if (pci_enabled  usb_enabled) {
+if (pci_enabled  usb_enabled(false)) {
 pci_create_simple(pci_bus, piix3_devfn + 2, piix3-usb-uhci);
 }
 
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index e95cfe8..1d4f494 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
 ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
 ide_mem[2] = pmac_ide_init(hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
pic[0x02]);
 
-/* cuda also initialize ADB */
-if (machine_arch == ARCH_MAC99_U3) {
-usb_enabled = 1;
-}
 cuda_init(cuda_mem, pic[0x19]);
 
 adb_kbd_init(adb_bus);
@@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
 
-if (usb_enabled) {
+if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
 pci_create_simple(pci_bus, -1, pci-ohci);
-}
-
-/* U3 needs to use USB for input because Linux doesn't support via-cuda
-   on PPC64 */
-if (machine_arch == ARCH_MAC99_U3) {
-usbdevice_create(keyboard);
-usbdevice_create(mouse);
+/* U3 needs to use USB for input because Linux doesn't support via-cuda
+on PPC64 */
+if (machine_arch == ARCH_MAC99_U3) {
+usbdevice_create(keyboard);
+usbdevice_create(mouse);
+}
 }
 
 if (graphic_depth != 15  graphic_depth != 32  graphic_depth != 8)
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 1dcd8a6..1468a32 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 pci_create_simple(pci_bus, -1, pci-ohci);
 }
 
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 592b7b2..a0888cd 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -660,7 +660,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
 memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 pci_create_simple(pci_bus, -1, pci-ohci);
 }
 
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index d5f1420..4787279 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
 s-ssp[i] = (SSIBus *)qdev_get_child_bus(dev, ssi);
 }
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 sysbus_create_simple(sysbus-ohci, 0x4c00,
 qdev_get_gpio_in(s-pic, PXA2XX_PIC_USBH1));
 }
@@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, 
unsigned int