Merge lp:~serge-hallyn/ubuntu/maverick/qemu-kvm/update-to-12.4 into lp:ubuntu/maverick/qemu-kvm

Proposed by Serge Hallyn
Status: Superseded
Proposed branch: lp:~serge-hallyn/ubuntu/maverick/qemu-kvm/update-to-12.4
Merge into: lp:ubuntu/maverick/qemu-kvm
Diff against target: 2838 lines (+645/-1148)
50 files modified
Changelog (+50/-0)
KVM_VERSION (+1/-1)
VERSION (+1/-1)
audio/ossaudio.c (+52/-20)
block.c (+11/-3)
block/qcow2-cluster.c (+1/-0)
block/qcow2-refcount.c (+248/-106)
block/qcow2.c (+11/-3)
debian/changelog (+11/-0)
debian/patches/0001-linux-user-adapt-uname-machine-to-emulated-CPU.patch (+0/-137)
debian/patches/05_improve-qemu-img-errors.patch (+0/-20)
debian/patches/Detect-and-use-GCC-atomic-builtins-for-locking.patch (+0/-87)
debian/patches/SDL-wrong-behaviour-of-caps-lock.patch (+0/-31)
debian/patches/This-patch-adds-support-for-the-pselect-syscall-in-l.patch (+0/-171)
debian/patches/arm-host-fix-compiler-warning.patch (+0/-90)
debian/patches/better_describe_-net_options.patch (+0/-60)
debian/patches/block_avoid_creating_too_large_iovecs_in_multiwrite_merge.patch (+0/-53)
debian/patches/series (+0/-8)
debian/rules (+11/-0)
default-configs/sh4-softmmu.mak (+1/-0)
default-configs/sh4eb-softmmu.mak (+1/-0)
dyngen-exec.h (+3/-3)
hw/device-assignment.c (+0/-75)
hw/fdc.c (+15/-5)
hw/fw_cfg.c (+1/-1)
hw/ide/cmd646.c (+2/-5)
hw/ide/internal.h (+1/-0)
hw/ide/piix.c (+1/-0)
hw/lsi53c895a.c (+84/-92)
hw/scsi-disk.c (+3/-1)
hw/sh7750.c (+5/-2)
hw/sh_pci.c (+15/-96)
hw/usb-uhci.c (+4/-3)
json-parser.c (+1/-1)
linux-user/main.c (+1/-1)
net.c (+0/-20)
net.h (+0/-1)
qemu-char.c (+1/-4)
qemu-common.h (+4/-0)
qemu-kvm.c (+5/-1)
qemu-options.hx (+1/-1)
target-i386/translate.c (+9/-6)
target-sh4/cpu.h (+2/-0)
target-sh4/helper.c (+20/-2)
target-sh4/translate.c (+1/-1)
tcg/arm/tcg-target.c (+7/-4)
tcg/mips/tcg-target.c (+33/-21)
tcg/mips/tcg-target.h (+3/-3)
vl.c (+20/-6)
vnc.c (+4/-2)
To merge this branch: bzr merge lp:~serge-hallyn/ubuntu/maverick/qemu-kvm/update-to-12.4
Reviewer Review Type Date Requested Status
Mathias Gug Needs Fixing
Dustin Kirkland  Pending
Ubuntu branches Pending
Review via email: mp+27293@code.launchpad.net

This proposal has been superseded by a proposal from 2010-06-15.

Description of the change

Forward port to qemu 0.12.4. Remove patches which have been
merged upstream. Remove the capslock patch since 0.12.3+noroms
(in lucid) with that patch does not behave correctly anyway.

Tweak debian/rules per kees' input to allow parallel=N
DEB_BUILD_OPTIONS.

To post a comment you must log in.
Revision history for this message
Mathias Gug (mathiaz) wrote :

Thanks for creating a merge proposal.

Looking at the last changelog entry for the last new upstream release (0.12.3+noroms-0ubuntu1) you'll notice that the upstream tarball cannot be used directly as it contains some binary BIOS roms whose sources are not available. Thus we need to repack the upstream tarball before importing it into the archive - thus the +noroms appended to the upstream revision. This is why a bunch of new binary files under pc-bios/ have been added to the branch (line 2326).

There should only be one changelog entry with the revision set to 0.12.4+noroms-0ubuntu1 (ie without ~hallyn1 - but I guess you already knew about that ;)). For the point "Removed the capslock patch..." I'd add a reference to the LP bug number using the notation: LP: #DDDDDD

In debian/rules (line ) what does line 1408 mean?:

  , := ,

review: Needs Fixing
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

On Fri, 2010-06-11 at 04:13 +0000, Mathias Gug wrote:
> Review: Needs Fixing
> Thanks for creating a merge proposal.
>
> Looking at the last changelog entry for the last new upstream release (0.12.3+noroms-0ubuntu1) you'll notice that the upstream tarball cannot be used directly as it contains some binary BIOS roms whose sources are not available. Thus we need to repack the upstream tarball before importing it into the archive - thus the +noroms appended to the upstream revision. This is why a bunch of new binary files under pc-bios/ have been added to the branch (line 2326).
>
> There should only be one changelog entry with the revision set to 0.12.4+noroms-0ubuntu1 (ie without ~hallyn1 - but I guess you already knew about that ;)). For the point "Removed the capslock patch..." I'd add a reference to the LP bug number using the notation: LP: #DDDDDD

Thanks for you help - I'm starting a new branch to address these, and
will resubmit that.

> In debian/rules (line ) what does line 1408 mean?:
>
> , := ,

I'm told it's needed to define a variable containing literal ',', which
is dereferenced later using $(,) :)

thanks,
-serge

76. By Serge Hallyn

New upstream release.

Built on top of new +noroms tarball.
TODO: consolidate all debian/changelog entries into 1.
 (in a new bzr branch presumably)

77. By Serge Hallyn

fix debian/changelog and remove binary roms

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Changelog'
2--- Changelog 2010-02-26 16:26:00 +0000
3+++ Changelog 2010-06-11 20:46:30 +0000
4@@ -1,3 +1,53 @@
5+version 0.12.4
6+ - Workaround for broken OSS_GETVERSION on FreeBSD, part two (Juergen Lock)
7+ - oss: fix fragment setting (malc)
8+ - oss: issue OSS_GETVERSION ioctl only when needed (malc)
9+ - oss: refactor code around policy setting (malc)
10+ - oss: workaround for cases when OSS_GETVERSION is not defined (malc)
11+ - block: Free iovec arrays allocated by multiwrite_merge() (Stefan Hajnoczi)
12+ - lsi: fix segfault in lsi_command_complete (Gerd Hoffmann)
13+ - lsi: pass lsi_request to lsi_reselect (Gerd Hoffmann)
14+ - lsi: move dma_len+dma_buf into lsi_request (Gerd Hoffmann)
15+ - lsi: move current_dev into lsi_request (Gerd Hoffmann)
16+ - lsi: have lsi_request for the whole life time of the request. (Gerd Hoffmann)
17+ - lsi: use QTAILQ for lsi_queue (Gerd Hoffmann)
18+ - tcp/mips: Change TCG_AREG0 (fp -> s0) (Stefan Weil)
19+ - sh_pci: fix memory and I/O access (Aurelien Jarno)
20+ - Fix incoming migration with iothread (Marcelo Tosatti)
21+ - Fix SIGFPE for vnc display of width/height = 1 (Chris Webb)
22+ - net: remove broken net_set_boot_mask() boot device validation (Eduardo Habkost)
23+ - qcow2: Remove request from in-flight list after error (Kevin Wolf)
24+ - qcow2: Don't ignore immediate read/write failures (Kevin Wolf)
25+ - block: Fix multiwrite memory leak in error case (Kevin Wolf)
26+ - block: Fix error code in multiwrite for immediate failures (Kevin Wolf)
27+ - block: Fix multiwrite error handling (Kevin Wolf)
28+ - scsi-disk: fix buffer overflow (Gerd Hoffmann)
29+ - qcow2: Rewrite alloc_refcount_block/grow_refcount_table (Kevin Wolf)
30+ - qcow2: Factor next_refcount_table_size out (Kevin Wolf)
31+ - block: avoid creating too large iovecs in multiwrite_merge (Christoph Hellwig)
32+ - json-parser: Fix segfault on malformed input (Kevin Wolf)
33+ - linux-user: switch default ppc64 CPU to 970fx from 970 (Aurelien Jarno)
34+ - target-sh4: MMU: fix store queue addresses (Aurelien Jarno)
35+ - target-sh4: MMU: fix ITLB priviledge check (Aurelien Jarno)
36+ - target-sh4: MMU: fix mem_idx computation (Aurelien Jarno)
37+ - sh7750: handle MMUCR TI bit (Aurelien Jarno)
38+ - UHCI spurious interrut fix (Paul Brook)
39+ - tcg/mips: fix branch offset during retranslation (Aurelien Jarno)
40+ - tcg/arm: correctly save/restore registers in prologue/epilogue (Aurelien Jarno)
41+ - workaround for cmd646 bmdma register access while no dma is active (Igor V. Kovalenko)
42+ - Fix corner case in chardev udp: parameter (Jan Kiszka)
43+ - Don't set default monitor when there is a mux'ed one (Jan Kiszka)
44+ - spelling typo (compatibilty) in hw/fw_cfg.c (Vagrant Cascadian)
45+ - fdc: fix drive property handling. (Gerd Hoffmann)
46+ - target-i386: fix commit c22549204a6edc431e8e4358e61bd56386ff6957 (TeLeMan)
47+ - target-i386: fix SIB decoding with index = 4 (Aurelien Jarno)
48+ - Fix segfault with ram_size > 4095M without kvm (Ryan Harper)
49+ - target-i386: Fix long jumps/calls in long mode with REX.W set (malc)
50+ - target-i386: fix lddqu SSE instruction (Aurelien Jarno)
51+ - qemu-char.c: drop debug printfs from qemu_chr_parse_compat (Jan Kiszka)
52+ - fix undefined shifts by >32 (Paolo Bonzini)
53+ - Fix qemu -net user,hostfwd= example (Aurelien Jarno)
54+
55 version 0.12.3
56 - kvm: Fix eflags corruption in kvm mode (Jan Kiszka)
57 - qcow2: Fix access after end of array (Kevin Wolf)
58
59=== modified file 'KVM_VERSION'
60--- KVM_VERSION 2010-02-26 16:26:00 +0000
61+++ KVM_VERSION 2010-06-11 20:46:30 +0000
62@@ -1,1 +1,1 @@
63-qemu-kvm-0.12.3
64+qemu-kvm-0.12.4
65
66=== modified file 'VERSION'
67--- VERSION 2010-02-26 16:26:00 +0000
68+++ VERSION 2010-06-11 20:46:30 +0000
69@@ -1,1 +1,1 @@
70-0.12.3
71+0.12.4
72
73=== modified file 'audio/ossaudio.c'
74--- audio/ossaudio.c 2010-01-20 17:54:24 +0000
75+++ audio/ossaudio.c 2010-06-11 20:46:30 +0000
76@@ -38,6 +38,10 @@
77 #define AUDIO_CAP "oss"
78 #include "audio_int.h"
79
80+#if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY
81+#define USE_DSP_POLICY
82+#endif
83+
84 typedef struct OSSVoiceOut {
85 HWVoiceOut hw;
86 void *pcm_buf;
87@@ -236,14 +240,39 @@
88 }
89 #endif
90
91+#ifdef USE_DSP_POLICY
92+static int oss_get_version (int fd, int *version, const char *typ)
93+{
94+ if (ioctl (fd, OSS_GETVERSION, &version)) {
95+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
96+ /*
97+ * Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
98+ * since 7.x, but currently only on the mixer device (or in
99+ * the Linuxolator), and in the native version that part of
100+ * the code is in fact never reached so the ioctl fails anyway.
101+ * Until this is fixed, just check the errno and if its what
102+ * FreeBSD's sound drivers return atm assume they are new enough.
103+ */
104+ if (errno == EINVAL) {
105+ *version = 0x040000;
106+ return 0;
107+ }
108+#endif
109+ oss_logerr2 (errno, typ, "Failed to get OSS version\n");
110+ return -1;
111+ }
112+ return 0;
113+}
114+#endif
115+
116 static int oss_open (int in, struct oss_params *req,
117 struct oss_params *obt, int *pfd)
118 {
119 int fd;
120- int version;
121 int oflags = conf.exclusive ? O_EXCL : 0;
122 audio_buf_info abinfo;
123 int fmt, freq, nchannels;
124+ int setfragment = 1;
125 const char *dspname = in ? conf.devpath_in : conf.devpath_out;
126 const char *typ = in ? "ADC" : "DAC";
127
128@@ -281,27 +310,30 @@
129 goto err;
130 }
131
132- if (ioctl (fd, OSS_GETVERSION, &version)) {
133- oss_logerr2 (errno, typ, "Failed to get OSS version\n");
134- version = 0;
135- }
136-
137- if (conf.debug) {
138- dolog ("OSS version = %#x\n", version);
139- }
140-
141-#ifdef SNDCTL_DSP_POLICY
142- if (conf.policy >= 0 && version >= 0x040000) {
143- int policy = conf.policy;
144- if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
145- oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n",
146- conf.policy);
147- goto err;
148+#ifdef USE_DSP_POLICY
149+ if (conf.policy >= 0) {
150+ int version;
151+
152+ if (!oss_get_version (fd, &version, typ)) {
153+ if (conf.debug) {
154+ dolog ("OSS version = %#x\n", version);
155+ }
156+
157+ if (version >= 0x040000) {
158+ int policy = conf.policy;
159+ if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
160+ oss_logerr2 (errno, typ,
161+ "Failed to set timing policy to %d\n",
162+ conf.policy);
163+ goto err;
164+ }
165+ setfragment = 0;
166+ }
167 }
168 }
169- else
170 #endif
171- {
172+
173+ if (setfragment) {
174 int mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize);
175 if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
176 oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
177@@ -857,7 +889,7 @@
178 .valp = &conf.exclusive,
179 .descr = "Open device in exclusive mode (vmix wont work)"
180 },
181-#ifdef SNDCTL_DSP_POLICY
182+#ifdef USE_DSP_POLICY
183 {
184 .name = "POLICY",
185 .tag = AUD_OPT_INT,
186
187=== modified file 'block.c'
188--- block.c 2010-02-26 16:26:00 +0000
189+++ block.c 2010-06-11 20:46:30 +0000
190@@ -1608,6 +1608,9 @@
191
192 for (i = 0; i < mcb->num_callbacks; i++) {
193 mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error);
194+ if (mcb->callbacks[i].free_qiov) {
195+ qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
196+ }
197 qemu_free(mcb->callbacks[i].free_qiov);
198 qemu_vfree(mcb->callbacks[i].free_buf);
199 }
200@@ -1617,7 +1620,7 @@
201 {
202 MultiwriteCB *mcb = opaque;
203
204- if (ret < 0) {
205+ if (ret < 0 && !mcb->error) {
206 mcb->error = ret;
207 multiwrite_user_cb(mcb);
208 }
209@@ -1669,6 +1672,10 @@
210 merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
211 }
212
213+ if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
214+ merge = 0;
215+ }
216+
217 if (merge) {
218 size_t size;
219 QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
220@@ -1754,10 +1761,11 @@
221 // submitted yet. Otherwise we'll wait for the submitted AIOs to
222 // complete and report the error in the callback.
223 if (mcb->num_requests == 0) {
224- reqs[i].error = EIO;
225+ reqs[i].error = -EIO;
226 goto fail;
227 } else {
228- mcb->error = EIO;
229+ mcb->num_requests++;
230+ multiwrite_cb(mcb, -EIO);
231 break;
232 }
233 } else {
234
235=== modified file 'block/qcow2-cluster.c'
236--- block/qcow2-cluster.c 2010-02-26 16:26:00 +0000
237+++ block/qcow2-cluster.c 2010-06-11 20:46:30 +0000
238@@ -811,6 +811,7 @@
239
240 cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
241 if (cluster_offset < 0) {
242+ QLIST_REMOVE(m, next_in_flight);
243 return cluster_offset;
244 }
245
246
247=== modified file 'block/qcow2-refcount.c'
248--- block/qcow2-refcount.c 2010-02-26 16:26:00 +0000
249+++ block/qcow2-refcount.c 2010-06-11 20:46:30 +0000
250@@ -27,7 +27,7 @@
251 #include "block/qcow2.h"
252
253 static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size);
254-static int update_refcount(BlockDriverState *bs,
255+static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
256 int64_t offset, int64_t length,
257 int addend);
258
259@@ -123,124 +123,266 @@
260 return be16_to_cpu(s->refcount_block_cache[block_index]);
261 }
262
263-static int grow_refcount_table(BlockDriverState *bs, int min_size)
264+/*
265+ * Rounds the refcount table size up to avoid growing the table for each single
266+ * refcount block that is allocated.
267+ */
268+static unsigned int next_refcount_table_size(BDRVQcowState *s,
269+ unsigned int min_size)
270+{
271+ unsigned int min_clusters = (min_size >> (s->cluster_bits - 3)) + 1;
272+ unsigned int refcount_table_clusters =
273+ MAX(1, s->refcount_table_size >> (s->cluster_bits - 3));
274+
275+ while (min_clusters > refcount_table_clusters) {
276+ refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2;
277+ }
278+
279+ return refcount_table_clusters << (s->cluster_bits - 3);
280+}
281+
282+
283+/* Checks if two offsets are described by the same refcount block */
284+static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a,
285+ uint64_t offset_b)
286+{
287+ uint64_t block_a = offset_a >> (2 * s->cluster_bits - REFCOUNT_SHIFT);
288+ uint64_t block_b = offset_b >> (2 * s->cluster_bits - REFCOUNT_SHIFT);
289+
290+ return (block_a == block_b);
291+}
292+
293+/*
294+ * Loads a refcount block. If it doesn't exist yet, it is allocated first
295+ * (including growing the refcount table if needed).
296+ *
297+ * Returns the offset of the refcount block on success or -errno in error case
298+ */
299+static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index)
300 {
301 BDRVQcowState *s = bs->opaque;
302- int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
303- uint64_t *new_table;
304- int64_t table_offset;
305+ unsigned int refcount_table_index;
306+ int ret;
307+
308+ /* Find the refcount block for the given cluster */
309+ refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
310+
311+ if (refcount_table_index < s->refcount_table_size) {
312+
313+ uint64_t refcount_block_offset =
314+ s->refcount_table[refcount_table_index];
315+
316+ /* If it's already there, we're done */
317+ if (refcount_block_offset) {
318+ if (refcount_block_offset != s->refcount_block_cache_offset) {
319+ ret = load_refcount_block(bs, refcount_block_offset);
320+ if (ret < 0) {
321+ return ret;
322+ }
323+ }
324+ return refcount_block_offset;
325+ }
326+ }
327+
328+ /*
329+ * If we came here, we need to allocate something. Something is at least
330+ * a cluster for the new refcount block. It may also include a new refcount
331+ * table if the old refcount table is too small.
332+ *
333+ * Note that allocating clusters here needs some special care:
334+ *
335+ * - We can't use the normal qcow2_alloc_clusters(), it would try to
336+ * increase the refcount and very likely we would end up with an endless
337+ * recursion. Instead we must place the refcount blocks in a way that
338+ * they can describe them themselves.
339+ *
340+ * - We need to consider that at this point we are inside update_refcounts
341+ * and doing the initial refcount increase. This means that some clusters
342+ * have already been allocated by the caller, but their refcount isn't
343+ * accurate yet. free_cluster_index tells us where this allocation ends
344+ * as long as we don't overwrite it by freeing clusters.
345+ *
346+ * - alloc_clusters_noref and qcow2_free_clusters may load a different
347+ * refcount block into the cache
348+ */
349+
350+ if (cache_refcount_updates) {
351+ ret = write_refcount_block(s);
352+ if (ret < 0) {
353+ return ret;
354+ }
355+ }
356+
357+ /* Allocate the refcount block itself and mark it as used */
358+ uint64_t new_block = alloc_clusters_noref(bs, s->cluster_size);
359+ memset(s->refcount_block_cache, 0, s->cluster_size);
360+ s->refcount_block_cache_offset = new_block;
361+
362+#ifdef DEBUG_ALLOC2
363+ fprintf(stderr, "qcow2: Allocate refcount block %d for %" PRIx64
364+ " at %" PRIx64 "\n",
365+ refcount_table_index, cluster_index << s->cluster_bits, new_block);
366+#endif
367+
368+ if (in_same_refcount_block(s, new_block, cluster_index << s->cluster_bits)) {
369+ /* The block describes itself, need to update the cache */
370+ int block_index = (new_block >> s->cluster_bits) &
371+ ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
372+ s->refcount_block_cache[block_index] = cpu_to_be16(1);
373+ } else {
374+ /* Described somewhere else. This can recurse at most twice before we
375+ * arrive at a block that describes itself. */
376+ ret = update_refcount(bs, new_block, s->cluster_size, 1);
377+ if (ret < 0) {
378+ goto fail_block;
379+ }
380+ }
381+
382+ /* Now the new refcount block needs to be written to disk */
383+ ret = bdrv_pwrite(s->hd, new_block, s->refcount_block_cache,
384+ s->cluster_size);
385+ if (ret < 0) {
386+ goto fail_block;
387+ }
388+
389+ /* If the refcount table is big enough, just hook the block up there */
390+ if (refcount_table_index < s->refcount_table_size) {
391+ uint64_t data64 = cpu_to_be64(new_block);
392+ ret = bdrv_pwrite(s->hd,
393+ s->refcount_table_offset + refcount_table_index * sizeof(uint64_t),
394+ &data64, sizeof(data64));
395+ if (ret < 0) {
396+ goto fail_block;
397+ }
398+
399+ s->refcount_table[refcount_table_index] = new_block;
400+ return new_block;
401+ }
402+
403+ /*
404+ * If we come here, we need to grow the refcount table. Again, a new
405+ * refcount table needs some space and we can't simply allocate to avoid
406+ * endless recursion.
407+ *
408+ * Therefore let's grab new refcount blocks at the end of the image, which
409+ * will describe themselves and the new refcount table. This way we can
410+ * reference them only in the new table and do the switch to the new
411+ * refcount table at once without producing an inconsistent state in
412+ * between.
413+ */
414+ /* Calculate the number of refcount blocks needed so far */
415+ uint64_t refcount_block_clusters = 1 << (s->cluster_bits - REFCOUNT_SHIFT);
416+ uint64_t blocks_used = (s->free_cluster_index +
417+ refcount_block_clusters - 1) / refcount_block_clusters;
418+
419+ /* And now we need at least one block more for the new metadata */
420+ uint64_t table_size = next_refcount_table_size(s, blocks_used + 1);
421+ uint64_t last_table_size;
422+ uint64_t blocks_clusters;
423+ do {
424+ uint64_t table_clusters = size_to_clusters(s, table_size);
425+ blocks_clusters = 1 +
426+ ((table_clusters + refcount_block_clusters - 1)
427+ / refcount_block_clusters);
428+ uint64_t meta_clusters = table_clusters + blocks_clusters;
429+
430+ last_table_size = table_size;
431+ table_size = next_refcount_table_size(s, blocks_used +
432+ ((meta_clusters + refcount_block_clusters - 1)
433+ / refcount_block_clusters));
434+
435+ } while (last_table_size != table_size);
436+
437+#ifdef DEBUG_ALLOC2
438+ fprintf(stderr, "qcow2: Grow refcount table %" PRId32 " => %" PRId64 "\n",
439+ s->refcount_table_size, table_size);
440+#endif
441+
442+ /* Create the new refcount table and blocks */
443+ uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
444+ s->cluster_size;
445+ uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
446+ uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
447+ uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
448+
449+ assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
450+
451+ /* Fill the new refcount table */
452+ memcpy(new_table, s->refcount_table,
453+ s->refcount_table_size * sizeof(uint64_t));
454+ new_table[refcount_table_index] = new_block;
455+
456+ int i;
457+ for (i = 0; i < blocks_clusters; i++) {
458+ new_table[blocks_used + i] = meta_offset + (i * s->cluster_size);
459+ }
460+
461+ /* Fill the refcount blocks */
462+ uint64_t table_clusters = size_to_clusters(s, table_size * sizeof(uint64_t));
463+ int block = 0;
464+ for (i = 0; i < table_clusters + blocks_clusters; i++) {
465+ new_blocks[block++] = cpu_to_be16(1);
466+ }
467+
468+ /* Write refcount blocks to disk */
469+ ret = bdrv_pwrite(s->hd, meta_offset, new_blocks,
470+ blocks_clusters * s->cluster_size);
471+ qemu_free(new_blocks);
472+ if (ret < 0) {
473+ goto fail_table;
474+ }
475+
476+ /* Write refcount table to disk */
477+ for(i = 0; i < table_size; i++) {
478+ cpu_to_be64s(&new_table[i]);
479+ }
480+
481+ ret = bdrv_pwrite(s->hd, table_offset, new_table,
482+ table_size * sizeof(uint64_t));
483+ if (ret < 0) {
484+ goto fail_table;
485+ }
486+
487+ for(i = 0; i < table_size; i++) {
488+ cpu_to_be64s(&new_table[i]);
489+ }
490+
491+ /* Hook up the new refcount table in the qcow2 header */
492 uint8_t data[12];
493- int old_table_size;
494- int64_t old_table_offset;
495-
496- if (min_size <= s->refcount_table_size)
497- return 0;
498- /* compute new table size */
499- refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3);
500- for(;;) {
501- if (refcount_table_clusters == 0) {
502- refcount_table_clusters = 1;
503- } else {
504- refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2;
505- }
506- new_table_size = refcount_table_clusters << (s->cluster_bits - 3);
507- if (min_size <= new_table_size)
508- break;
509- }
510-#ifdef DEBUG_ALLOC2
511- printf("grow_refcount_table from %d to %d\n",
512- s->refcount_table_size,
513- new_table_size);
514-#endif
515- new_table_size2 = new_table_size * sizeof(uint64_t);
516- new_table = qemu_mallocz(new_table_size2);
517- memcpy(new_table, s->refcount_table,
518- s->refcount_table_size * sizeof(uint64_t));
519- for(i = 0; i < s->refcount_table_size; i++)
520- cpu_to_be64s(&new_table[i]);
521- /* Note: we cannot update the refcount now to avoid recursion */
522- table_offset = alloc_clusters_noref(bs, new_table_size2);
523- ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2);
524- if (ret != new_table_size2)
525- goto fail;
526- for(i = 0; i < s->refcount_table_size; i++)
527- be64_to_cpus(&new_table[i]);
528-
529 cpu_to_be64w((uint64_t*)data, table_offset);
530- cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters);
531+ cpu_to_be32w((uint32_t*)(data + 8), table_clusters);
532 ret = bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset),
533- data, sizeof(data));
534- if (ret != sizeof(data)) {
535- goto fail;
536+ data, sizeof(data));
537+ if (ret < 0) {
538+ goto fail_table;
539 }
540
541+ /* And switch it in memory */
542+ uint64_t old_table_offset = s->refcount_table_offset;
543+ uint64_t old_table_size = s->refcount_table_size;
544+
545 qemu_free(s->refcount_table);
546- old_table_offset = s->refcount_table_offset;
547- old_table_size = s->refcount_table_size;
548 s->refcount_table = new_table;
549- s->refcount_table_size = new_table_size;
550+ s->refcount_table_size = table_size;
551 s->refcount_table_offset = table_offset;
552
553- update_refcount(bs, table_offset, new_table_size2, 1);
554+ /* Free old table. Remember, we must not change free_cluster_index */
555+ uint64_t old_free_cluster_index = s->free_cluster_index;
556 qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
557- return 0;
558- fail:
559+ s->free_cluster_index = old_free_cluster_index;
560+
561+ ret = load_refcount_block(bs, new_block);
562+ if (ret < 0) {
563+ goto fail_block;
564+ }
565+
566+ return new_block;
567+
568+fail_table:
569 qemu_free(new_table);
570- return ret < 0 ? ret : -EIO;
571-}
572-
573-
574-static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index)
575-{
576- BDRVQcowState *s = bs->opaque;
577- int64_t offset, refcount_block_offset;
578- unsigned int refcount_table_index;
579- int ret;
580- uint64_t data64;
581- int cache = cache_refcount_updates;
582-
583- /* Find L1 index and grow refcount table if needed */
584- refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
585- if (refcount_table_index >= s->refcount_table_size) {
586- ret = grow_refcount_table(bs, refcount_table_index + 1);
587- if (ret < 0)
588- return ret;
589- }
590-
591- /* Load or allocate the refcount block */
592- refcount_block_offset = s->refcount_table[refcount_table_index];
593- if (!refcount_block_offset) {
594- if (cache_refcount_updates) {
595- write_refcount_block(s);
596- cache_refcount_updates = 0;
597- }
598- /* create a new refcount block */
599- /* Note: we cannot update the refcount now to avoid recursion */
600- offset = alloc_clusters_noref(bs, s->cluster_size);
601- memset(s->refcount_block_cache, 0, s->cluster_size);
602- ret = bdrv_pwrite(s->hd, offset, s->refcount_block_cache, s->cluster_size);
603- if (ret != s->cluster_size)
604- return -EINVAL;
605- s->refcount_table[refcount_table_index] = offset;
606- data64 = cpu_to_be64(offset);
607- ret = bdrv_pwrite(s->hd, s->refcount_table_offset +
608- refcount_table_index * sizeof(uint64_t),
609- &data64, sizeof(data64));
610- if (ret != sizeof(data64))
611- return -EINVAL;
612-
613- refcount_block_offset = offset;
614- s->refcount_block_cache_offset = offset;
615- update_refcount(bs, offset, s->cluster_size, 1);
616- cache_refcount_updates = cache;
617- } else {
618- if (refcount_block_offset != s->refcount_block_cache_offset) {
619- if (load_refcount_block(bs, refcount_block_offset) < 0)
620- return -EIO;
621- }
622- }
623-
624- return refcount_block_offset;
625+fail_block:
626+ s->refcount_block_cache_offset = 0;
627+ return ret;
628 }
629
630 #define REFCOUNTS_PER_SECTOR (512 >> REFCOUNT_SHIFT)
631
632=== modified file 'block/qcow2.c'
633--- block/qcow2.c 2010-02-26 16:26:00 +0000
634+++ block/qcow2.c 2010-06-11 20:46:30 +0000
635@@ -467,8 +467,10 @@
636 acb->hd_aiocb = bdrv_aio_readv(s->hd,
637 (acb->cluster_offset >> 9) + index_in_cluster,
638 &acb->hd_qiov, acb->n, qcow_aio_read_cb, acb);
639- if (acb->hd_aiocb == NULL)
640+ if (acb->hd_aiocb == NULL) {
641+ ret = -EIO;
642 goto done;
643+ }
644 }
645
646 return;
647@@ -620,11 +622,17 @@
648 (acb->cluster_offset >> 9) + index_in_cluster,
649 &acb->hd_qiov, acb->n,
650 qcow_aio_write_cb, acb);
651- if (acb->hd_aiocb == NULL)
652- goto done;
653+ if (acb->hd_aiocb == NULL) {
654+ ret = -EIO;
655+ goto fail;
656+ }
657
658 return;
659
660+fail:
661+ if (acb->l2meta.nb_clusters != 0) {
662+ QLIST_REMOVE(&acb->l2meta, next_in_flight);
663+ }
664 done:
665 if (acb->qiov->niov > 1)
666 qemu_vfree(acb->orig_buf);
667
668=== modified file 'debian/changelog'
669--- debian/changelog 2010-04-23 18:45:55 +0000
670+++ debian/changelog 2010-06-11 20:46:30 +0000
671@@ -1,3 +1,14 @@
672+qemu-kvm (0.12.4+noroms-0ubuntu1) maverick; urgency=low
673+
674+ * New upstream release.
675+ * add block from kees to debian/rules to parallelize make
676+ * Removed patches which have been merged.
677+ * Removed the capslock patch because capslock isn't behaving
678+ right for me in 0.12.3 with the patch anyway, probably bc the
679+ underlying SDL has been fixed. Original patch was for LP#427612.
680+
681+ -- Serge Hallyn <serge.hallyn@canonical.com> Fri, 11 Jun 2010 11:58:47 -0500
682+
683 qemu-kvm (0.12.3+noroms-0ubuntu9) lucid; urgency=low
684
685 * Architecture-specific fixes (LP: #568904)
686
687=== removed file 'debian/patches/0001-linux-user-adapt-uname-machine-to-emulated-CPU.patch'
688--- debian/patches/0001-linux-user-adapt-uname-machine-to-emulated-CPU.patch 2010-01-20 17:54:24 +0000
689+++ debian/patches/0001-linux-user-adapt-uname-machine-to-emulated-CPU.patch 1970-01-01 00:00:00 +0000
690@@ -1,137 +0,0 @@
691-http://lists.gnu.org/archive/html/qemu-devel/2010-01/msg01114.html
692-
693-From: Loic Minier
694-Date: Tue, 29 Dec 2009 22:06:13 +0100
695-Subject: [PATCH] linux-user: adapt uname machine to emulated CPU
696-
697----
698- Makefile.target | 2 +-
699- linux-user/cpu-uname.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
700- linux-user/cpu-uname.h | 1 +
701- linux-user/syscall.c | 3 +-
702- 4 files changed, 76 insertions(+), 2 deletions(-)
703- create mode 100644 linux-user/cpu-uname.c
704- create mode 100644 linux-user/cpu-uname.h
705-
706-diff --git a/Makefile.target b/Makefile.target
707-index e661478..9f5bd17 100644
708---- a/Makefile.target
709-+++ b/Makefile.target
710-@@ -95,7 +95,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR
711-
712- QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
713- obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \
714-- elfload.o linuxload.o uaccess.o gdbstub.o
715-+ elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o
716-
717- obj-$(TARGET_HAS_BFLT) += flatload.o
718- obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o
719-diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c
720-new file mode 100644
721-index 0000000..ddc37be
722---- /dev/null
723-+++ b/linux-user/cpu-uname.c
724-@@ -0,0 +1,72 @@
725-+/*
726-+ * cpu to uname machine name map
727-+ *
728-+ * Copyright (c) 2009 Loïc Minier
729-+ *
730-+ * This program is free software; you can redistribute it and/or modify
731-+ * it under the terms of the GNU General Public License as published by
732-+ * the Free Software Foundation; either version 2 of the License, or
733-+ * (at your option) any later version.
734-+ *
735-+ * This program is distributed in the hope that it will be useful,
736-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
737-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
738-+ * GNU General Public License for more details.
739-+ *
740-+ * You should have received a copy of the GNU General Public License
741-+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
742-+ */
743-+
744-+#include <stdio.h>
745-+
746-+#include "qemu.h"
747-+//#include "qemu-common.h"
748-+#include "cpu-uname.h"
749-+
750-+/* return highest utsname machine name for emulated instruction set
751-+ *
752-+ * NB: the default emulated CPU ("any") might not match any existing CPU, e.g.
753-+ * on ARM it has all features turned on, so there is no perfect arch string to
754-+ * return here */
755-+const char *cpu_to_uname_machine(void *cpu_env)
756-+{
757-+#ifdef TARGET_ARM
758-+ /* utsname machine name on linux arm is CPU arch name + endianness, e.g.
759-+ * armv7l; to get a list of CPU arch names from the linux source, use:
760-+ * grep arch_name: -A1 linux/arch/arm/mm/proc-*.S
761-+ * see arch/arm/kernel/setup.c: setup_processor()
762-+ *
763-+ * to test by CPU id, compare cpu_env->cp15.c0_cpuid to ARM_CPUID_*
764-+ * defines and to test by CPU feature, use arm_feature(cpu_env,
765-+ * ARM_FEATURE_*) */
766-+
767-+ /* in theory, endianness is configurable on some ARM CPUs, but this isn't
768-+ * used in user mode emulation */
769-+#ifdef TARGET_WORDS_BIGENDIAN
770-+#define utsname_suffix "b"
771-+#else
772-+#define utsname_suffix "l"
773-+#endif
774-+ if (arm_feature(cpu_env, ARM_FEATURE_V7))
775-+ return "armv7" utsname_suffix;
776-+ if (arm_feature(cpu_env, ARM_FEATURE_V6))
777-+ return "armv6" utsname_suffix;
778-+ /* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its
779-+ * Jazelle support */
780-+ return "armv5te" utsname_suffix;
781-+#elif defined(TARGET_X86_64)
782-+ return "x86-64";
783-+#elif defined(TARGET_I386)
784-+ /* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */
785-+ uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version;
786-+ int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff);
787-+ if (family == 4)
788-+ return "i486";
789-+ if (family == 5)
790-+ return "i586";
791-+ return "i686";
792-+#else
793-+ /* default is #define-d in each arch/ subdir */
794-+ return UNAME_MACHINE;
795-+#endif
796-+}
797-diff --git a/linux-user/cpu-uname.h b/linux-user/cpu-uname.h
798-new file mode 100644
799-index 0000000..32492de
800---- /dev/null
801-+++ b/linux-user/cpu-uname.h
802-@@ -0,0 +1 @@
803-+const char *cpu_to_uname_machine(void *cpu_env);
804-diff --git a/linux-user/syscall.c b/linux-user/syscall.c
805-index f2dd39e..9fb493f 100644
806---- a/linux-user/syscall.c
807-+++ b/linux-user/syscall.c
808-@@ -82,6 +82,7 @@
809- #include <linux/fb.h>
810- #include <linux/vt.h>
811- #include "linux_loop.h"
812-+#include "cpu-uname.h"
813-
814- #include "qemu.h"
815- #include "qemu-common.h"
816-@@ -5739,7 +5740,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
817- if (!is_error(ret)) {
818- /* Overrite the native machine name with whatever is being
819- emulated. */
820-- strcpy (buf->machine, UNAME_MACHINE);
821-+ strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
822- /* Allow the user to override the reported release. */
823- if (qemu_uname_release && *qemu_uname_release)
824- strcpy (buf->release, qemu_uname_release);
825---
826-1.6.5
827-
828
829=== removed file 'debian/patches/05_improve-qemu-img-errors.patch'
830--- debian/patches/05_improve-qemu-img-errors.patch 2009-09-10 22:58:09 +0000
831+++ debian/patches/05_improve-qemu-img-errors.patch 1970-01-01 00:00:00 +0000
832@@ -1,20 +0,0 @@
833-qemu-img: improve error reporting
834-
835-Use strerror to provide a better error message when qemu-img fails.
836-
837-https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/418112
838-
839-Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
840-
841-diff -uprN qemu-kvm-0.11.0~rc2/qemu-img.c qemu-kvm-0.11.0~rc2.new/qemu-img.c
842---- qemu-kvm-0.11.0~rc2/qemu-img.c 2009-08-30 04:10:59.000000000 -0500
843-+++ qemu-kvm-0.11.0~rc2.new/qemu-img.c 2009-09-10 22:30:32.572211443 -0500
844-@@ -368,7 +368,7 @@ static int img_create(int argc, char **a
845- } else if (ret == -EFBIG) {
846- error("The image size is too large for file format '%s'", fmt);
847- } else {
848-- error("Error while formatting");
849-+ error("Error while formatting (%s)", strerror(-ret));
850- }
851- }
852- return 0;
853
854=== removed file 'debian/patches/Detect-and-use-GCC-atomic-builtins-for-locking.patch'
855--- debian/patches/Detect-and-use-GCC-atomic-builtins-for-locking.patch 2010-02-18 14:08:33 +0000
856+++ debian/patches/Detect-and-use-GCC-atomic-builtins-for-locking.patch 1970-01-01 00:00:00 +0000
857@@ -1,87 +0,0 @@
858-From de01f17a2cb88dc5ff53cc321342b888c33b120a Mon Sep 17 00:00:00 2001
859-From: =?UTF-8?q?Lo=C3=AFc=20Minier?= <lool@dooz.org>
860-Date: Thu, 11 Feb 2010 17:42:33 +0100
861-Subject: [PATCH] Detect and use GCC atomic builtins for locking
862-
863----
864- configure | 17 +++++++++++++++++
865- qemu-lock.h | 13 +++++++++++++
866- 2 files changed, 30 insertions(+), 0 deletions(-)
867-
868-diff --git a/configure b/configure
869-index 0a84b0e..b33f045 100755
870---- a/configure
871-+++ b/configure
872-@@ -1823,6 +1823,20 @@ if compile_prog "" ""; then
873- fi
874-
875- ##########################################
876-+# check if we have gcc atomic built-ins
877-+gcc_atomic_builtins=no
878-+cat > $TMPC << EOF
879-+int main(void) {
880-+ int i;
881-+ __sync_lock_test_and_set(&i, 1);
882-+ __sync_lock_release(&i);
883-+}
884-+EOF
885-+if compile_prog "" ""; then
886-+ gcc_atomic_builtins=yes
887-+fi
888-+
889-+##########################################
890- # check if we have fdatasync
891-
892- fdatasync=no
893-@@ -2168,6 +2182,9 @@ fi
894- if test "$gcc_attribute_warn_unused_result" = "yes" ; then
895- echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
896- fi
897-+if test "$gcc_atomic_builtins" = "yes" ; then
898-+ echo "CONFIG_GCC_ATOMIC_BUILTINS=y" >> $config_host_mak
899-+fi
900- if test "$fdatasync" = "yes" ; then
901- echo "CONFIG_FDATASYNC=y" >> $config_host_mak
902- fi
903-diff --git a/qemu-lock.h b/qemu-lock.h
904-index 9a3e6ac..5c8eb34 100644
905---- a/qemu-lock.h
906-+++ b/qemu-lock.h
907-@@ -33,6 +33,14 @@
908-
909- #else
910-
911-+#ifdef CONFIG_GCC_ATOMIC_BUILTINS
912-+typedef int spinlock_t;
913-+
914-+#define SPIN_LOCK_UNLOCKED 0
915-+
916-+#define resetlock(p) __sync_lock_release((p))
917-+#else /* CONFIG_GCC_ATOMIC_BUILTINS */
918-+
919- #if defined(__hppa__)
920-
921- typedef int spinlock_t[4];
922-@@ -56,7 +64,11 @@ static inline void resetlock (spinlock_t *p)
923- }
924-
925- #endif
926-+#endif /* !CONFIG_GCC_ATOMIC_BUILTINS */
927-
928-+#ifdef CONFIG_GCC_ATOMIC_BUILTINS
929-+#define testandset(p) __sync_lock_test_and_set((p), 1)
930-+#else /* CONFIG_GCC_ATOMIC_BUILTINS */
931- #if defined(_ARCH_PPC)
932- static inline int testandset (int *p)
933- {
934-@@ -213,6 +225,7 @@ static inline int testandset (int *p)
935- #else
936- #error unimplemented CPU support
937- #endif
938-+#endif /* !CONFIG_GCC_ATOMIC_BUILTINS */
939-
940- #if defined(CONFIG_USER_ONLY)
941- static inline void spin_lock(spinlock_t *lock)
942---
943-1.6.6.1
944-
945
946=== removed file 'debian/patches/SDL-wrong-behaviour-of-caps-lock.patch'
947--- debian/patches/SDL-wrong-behaviour-of-caps-lock.patch 2010-04-01 00:22:02 +0000
948+++ debian/patches/SDL-wrong-behaviour-of-caps-lock.patch 1970-01-01 00:00:00 +0000
949@@ -1,31 +0,0 @@
950-From bb212d2b23bee1abe52db53231caccc1a6a27791 Mon Sep 17 00:00:00 2001
951-From: Shahar Havivi <shaharh@redhat.com>
952-Date: Fri, 12 Feb 2010 00:00:44 +0200
953-Subject: [PATCH] Qemu does not pass pressed capslock to client
954-
955----
956- sdl.c | 8 +++++---
957- 1 files changed, 5 insertions(+), 3 deletions(-)
958-
959-diff --git a/sdl.c b/sdl.c
960-index cf27ad2..9074641 100644
961---- a/sdl.c
962-+++ b/sdl.c
963-@@ -390,9 +390,11 @@ static void sdl_process_key(SDL_KeyboardEvent *ev)
964- break;
965- case 0x45: /* num lock */
966- case 0x3a: /* caps lock */
967-- /* SDL does not send the key up event, so we generate it */
968-- kbd_put_keycode(keycode);
969-- kbd_put_keycode(keycode | 0x80);
970-+ if (ev->type == SDL_KEYUP) {
971-+ kbd_put_keycode(keycode | 0x80);
972-+ } else {
973-+ kbd_put_keycode(keycode);
974-+ }
975- return;
976- }
977-
978---
979-1.6.3.3
980-
981
982=== removed file 'debian/patches/This-patch-adds-support-for-the-pselect-syscall-in-l.patch'
983--- debian/patches/This-patch-adds-support-for-the-pselect-syscall-in-l.patch 2010-02-18 14:08:33 +0000
984+++ debian/patches/This-patch-adds-support-for-the-pselect-syscall-in-l.patch 1970-01-01 00:00:00 +0000
985@@ -1,171 +0,0 @@
986-From 2c28192f9eb4a23cda0787c97cdb78c33735803e Mon Sep 17 00:00:00 2001
987-From: Michael Casadevall <mcasadevall@ubuntu.com>
988-Date: Tue, 16 Feb 2010 05:31:19 -0500
989-Subject: [PATCH] This patch adds support for the pselect syscall in linux-user emulation and also adds several support functions required to translate the timespec structs between the target and the host.
990-
991-Signed-off-by: Michael Casadevall <mcasadevall@ubuntu.com>
992----
993- linux-user/arm/syscall_nr.h | 2 +-
994- linux-user/syscall.c | 119 +++++++++++++++++++++++++++++++++++++++++++
995- 2 files changed, 120 insertions(+), 1 deletions(-)
996-
997-diff --git a/linux-user/arm/syscall_nr.h b/linux-user/arm/syscall_nr.h
998-index b1db341..79a216a 100644
999---- a/linux-user/arm/syscall_nr.h
1000-+++ b/linux-user/arm/syscall_nr.h
1001-@@ -338,7 +338,7 @@
1002- #define TARGET_NR_readlinkat (332)
1003- #define TARGET_NR_fchmodat (333)
1004- #define TARGET_NR_faccessat (334)
1005-- /* 335 for pselect6 */
1006-+#define TARGET_NR_pselect6 (335)
1007- /* 336 for ppoll */
1008- #define TARGET_NR_unshare (337)
1009- #define TARGET_NR_set_robust_list (338)
1010-diff --git a/linux-user/syscall.c b/linux-user/syscall.c
1011-index 9fb493f..3663451 100644
1012---- a/linux-user/syscall.c
1013-+++ b/linux-user/syscall.c
1014-@@ -850,6 +850,38 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
1015- return 0;
1016- }
1017-
1018-+static inline abi_long copy_from_user_timespec(struct timespec *ts,
1019-+ abi_ulong target_ts_addr)
1020-+{
1021-+ struct target_timespec *target_ts;
1022-+
1023-+ if (!lock_user_struct(VERIFY_READ, target_ts, target_ts_addr, 1))
1024-+ return -TARGET_EFAULT;
1025-+
1026-+ __get_user(ts->tv_sec, &target_ts->tv_sec);
1027-+ __get_user(ts->tv_nsec, &target_ts->tv_nsec);
1028-+
1029-+ unlock_user_struct(target_ts, target_ts_addr, 0);
1030-+
1031-+ return 0;
1032-+}
1033-+
1034-+
1035-+static inline abi_long copy_to_user_timespec(abi_ulong target_ts_addr,
1036-+ const struct timespec *ts)
1037-+{
1038-+ struct target_timespec *target_ts;
1039-+
1040-+ if (!lock_user_struct(VERIFY_WRITE, target_ts, target_ts_addr, 0))
1041-+ return -TARGET_EFAULT;
1042-+
1043-+ __put_user(ts->tv_sec, &target_ts->tv_sec);
1044-+ __put_user(ts->tv_nsec, &target_ts->tv_nsec);
1045-+
1046-+ unlock_user_struct(target_ts, target_ts_addr, 1);
1047-+
1048-+ return 0;
1049-+}
1050- #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
1051- #include <mqueue.h>
1052-
1053-@@ -949,6 +981,75 @@ static abi_long do_select(int n,
1054- return ret;
1055- }
1056-
1057-+#ifdef TARGET_NR_pselect6
1058-+/* do_pselect() must return target values and target errnos. */
1059-+static abi_long do_pselect(int n,
1060-+ abi_ulong rfd_addr, abi_ulong wfd_addr,
1061-+ abi_ulong efd_addr, abi_ulong target_tv_addr,
1062-+ abi_ulong set_addr)
1063-+{
1064-+ fd_set rfds, wfds, efds;
1065-+ fd_set *rfds_ptr, *wfds_ptr, *efds_ptr;
1066-+ struct timespec tv, *tv_ptr;
1067-+ sigset_t set, *set_ptr;
1068-+ abi_long ret;
1069-+
1070-+ if (rfd_addr) {
1071-+ if (copy_from_user_fdset(&rfds, rfd_addr, n))
1072-+ return -TARGET_EFAULT;
1073-+ rfds_ptr = &rfds;
1074-+ } else {
1075-+ rfds_ptr = NULL;
1076-+ }
1077-+ if (wfd_addr) {
1078-+ if (copy_from_user_fdset(&wfds, wfd_addr, n))
1079-+ return -TARGET_EFAULT;
1080-+ wfds_ptr = &wfds;
1081-+ } else {
1082-+ wfds_ptr = NULL;
1083-+ }
1084-+ if (efd_addr) {
1085-+ if (copy_from_user_fdset(&efds, efd_addr, n))
1086-+ return -TARGET_EFAULT;
1087-+ efds_ptr = &efds;
1088-+ } else {
1089-+ efds_ptr = NULL;
1090-+ }
1091-+
1092-+ if (target_tv_addr) {
1093-+ if (copy_from_user_timespec(&tv, target_tv_addr))
1094-+ return -TARGET_EFAULT;
1095-+ tv_ptr = &tv;
1096-+ } else {
1097-+ tv_ptr = NULL;
1098-+ }
1099-+
1100-+ /* We don't need to return sigmask to target */
1101-+ if (set_addr) {
1102-+ target_to_host_old_sigset(&set, &set_addr);
1103-+ set_ptr = &set;
1104-+ } else {
1105-+ set_ptr = NULL;
1106-+ }
1107-+
1108-+ ret = get_errno(pselect(n, rfds_ptr, wfds_ptr, efds_ptr, tv_ptr, set_ptr));
1109-+
1110-+ if (!is_error(ret)) {
1111-+ if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n))
1112-+ return -TARGET_EFAULT;
1113-+ if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n))
1114-+ return -TARGET_EFAULT;
1115-+ if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n))
1116-+ return -TARGET_EFAULT;
1117-+
1118-+ if (target_tv_addr && copy_to_user_timespec(target_tv_addr, &tv))
1119-+ return -TARGET_EFAULT;
1120-+ }
1121-+
1122-+ return ret;
1123-+}
1124-+#endif
1125-+
1126- static abi_long do_pipe2(int host_pipe[], int flags)
1127- {
1128- #ifdef CONFIG_PIPE2
1129-@@ -5136,6 +5237,24 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
1130- }
1131- break;
1132- #endif
1133-+
1134-+#ifdef TARGET_NR_pselect6
1135-+ case TARGET_NR_pselect6:
1136-+ {
1137-+ abi_ulong inp, outp, exp, tvp, set;
1138-+ long nsel;
1139-+
1140-+ nsel = tswapl(arg1);
1141-+ inp = tswapl(arg2);
1142-+ outp = tswapl(arg3);
1143-+ exp = tswapl(arg4);
1144-+ tvp = tswapl(arg5);
1145-+ set = tswapl(arg6);
1146-+
1147-+ ret = do_pselect(nsel, inp, outp, exp, tvp, set);
1148-+ }
1149-+ break;
1150-+#endif
1151- case TARGET_NR_symlink:
1152- {
1153- void *p2;
1154---
1155-1.6.6.1
1156-
1157
1158=== removed file 'debian/patches/arm-host-fix-compiler-warning.patch'
1159--- debian/patches/arm-host-fix-compiler-warning.patch 2010-02-27 11:59:10 +0000
1160+++ debian/patches/arm-host-fix-compiler-warning.patch 1970-01-01 00:00:00 +0000
1161@@ -1,90 +0,0 @@
1162-From bc4347b883e8175dadef77ed9e02ccaa5e8eba94 Mon Sep 17 00:00:00 2001
1163-From: Stefan Weil <weil@mail.berlios.de>
1164-Date: Wed, 20 Jan 2010 19:43:25 +0100
1165-Subject: [PATCH] arm host: fix compiler warning
1166-MIME-Version: 1.0
1167-Content-Type: text/plain; charset=UTF-8
1168-Content-Transfer-Encoding: 8bit
1169-
1170-Compilation for arm (native or cross) results in this
1171-warning:
1172-
1173-fpu/softfloat-native.c: In function ‘float64_round_to_int’:
1174-fpu/softfloat-native.c:387: error: control reaches end of non-void function
1175-
1176-float64_round_to_int uses special assembler code for arm
1177-and has no explicit return value.
1178-
1179-As there is no obvious reason why arm should need special
1180-code, all fpu related conditionals were removed.
1181-The remaining code is standard (C99) and compiles for arm,
1182-too.
1183-
1184-Signed-off-by: Stefan Weil <weil@mail.berlios.de>
1185-Acked-by: Laurent Desnogues <laurent.desnogues@gmail.com>
1186-Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
1187----
1188- fpu/softfloat-native.c | 20 --------------------
1189- fpu/softfloat-native.h | 7 -------
1190- 2 files changed, 0 insertions(+), 27 deletions(-)
1191-
1192-diff --git a/fpu/softfloat-native.c b/fpu/softfloat-native.c
1193-index 8d64f4e..049c830 100644
1194---- a/fpu/softfloat-native.c
1195-+++ b/fpu/softfloat-native.c
1196-@@ -12,8 +12,6 @@ void set_float_rounding_mode(int val STATUS_PARAM)
1197- #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) || \
1198- (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
1199- fpsetround(val);
1200--#elif defined(__arm__)
1201-- /* nothing to do */
1202- #else
1203- fesetround(val);
1204- #endif
1205-@@ -365,25 +363,7 @@ float64 float64_trunc_to_int( float64 a STATUS_PARAM )
1206-
1207- float64 float64_round_to_int( float64 a STATUS_PARAM )
1208- {
1209--#if defined(__arm__)
1210-- switch(STATUS(float_rounding_mode)) {
1211-- default:
1212-- case float_round_nearest_even:
1213-- asm("rndd %0, %1" : "=f" (a) : "f"(a));
1214-- break;
1215-- case float_round_down:
1216-- asm("rnddm %0, %1" : "=f" (a) : "f"(a));
1217-- break;
1218-- case float_round_up:
1219-- asm("rnddp %0, %1" : "=f" (a) : "f"(a));
1220-- break;
1221-- case float_round_to_zero:
1222-- asm("rnddz %0, %1" : "=f" (a) : "f"(a));
1223-- break;
1224-- }
1225--#else
1226- return rint(a);
1227--#endif
1228- }
1229-
1230- float64 float64_rem( float64 a, float64 b STATUS_PARAM)
1231-diff --git a/fpu/softfloat-native.h b/fpu/softfloat-native.h
1232-index fe737b3..6da0bcb 100644
1233---- a/fpu/softfloat-native.h
1234-+++ b/fpu/softfloat-native.h
1235-@@ -126,13 +126,6 @@ enum {
1236- float_round_up = FP_RP,
1237- float_round_to_zero = FP_RZ
1238- };
1239--#elif defined(__arm__)
1240--enum {
1241-- float_round_nearest_even = 0,
1242-- float_round_down = 1,
1243-- float_round_up = 2,
1244-- float_round_to_zero = 3
1245--};
1246- #else
1247- enum {
1248- float_round_nearest_even = FE_TONEAREST,
1249---
1250-1.7.0
1251-
1252
1253=== removed file 'debian/patches/better_describe_-net_options.patch'
1254--- debian/patches/better_describe_-net_options.patch 2010-03-05 18:39:19 +0000
1255+++ debian/patches/better_describe_-net_options.patch 1970-01-01 00:00:00 +0000
1256@@ -1,60 +0,0 @@
1257-[PATCH] better describe -net options
1258-
1259-The manpage reflects that multiple -net user calls may be made,
1260-but if this is done, it can cause the program to hang. Instead,
1261-multiple -net calls can be combined into one, and this patch adds
1262-that information to qemu-options.hx. Also, -net user may only
1263-be used in conjunction with -net nic. This is already implcitly
1264-stated, but this patch makes that statement more explicit.
1265-
1266-https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/474969
1267-https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/453617
1268-
1269-Signed-off-by: Brian Thomason <brian.thomason@canonical.com>
1270----
1271- qemu-options.hx | 15 +++++++++++++--
1272- 1 files changed, 13 insertions(+), 2 deletions(-)
1273-
1274-diff --git a/qemu-options.hx b/qemu-options.hx
1275-index fd50add..724f434 100644
1276---- a/qemu-options.hx
1277-+++ b/qemu-options.hx
1278-@@ -952,7 +952,8 @@ for a list of available devices for your target.
1279-
1280- @item -net user[,@var{option}][,@var{option}][,...]
1281- Use the user mode network stack which requires no administrator
1282--privilege to run. Valid options are:
1283-+privilege to run. Please note that this can be used only in conjunction with
1284-+@option{-net nic}. Valid options are:
1285-
1286- @table @option
1287- @item vlan=@var{n}
1288-@@ -1028,7 +1029,8 @@ the guest IP address @var{guestaddr} on guest port @var{guestport}. If
1289- @var{guestaddr} is not specified, its value is x.x.x.15 (default first address
1290- given by the built-in DHCP server). By specifying @var{hostaddr}, the rule can
1291- be bound to a specific host interface. If no connection type is set, TCP is
1292--used. This option can be given multiple times.
1293-+used. This option can not be given multiple times, but multiple rules may
1294-+be combined.
1295-
1296- For example, to redirect host X11 connection from screen 1 to guest
1297- screen 0, use the following:
1298-@@ -1052,6 +1054,15 @@ telnet localhost 5555
1299- Then when you use on the host @code{telnet localhost 5555}, you
1300- connect to the guest telnet server.
1301-
1302-+To combine two or more hostfwd rules, simply use a comma as a delimiter. For
1303-+example, to combine the two rules mentioned in the examples above, use the
1304-+following:
1305-+
1306-+@example
1307-+#on the host
1308-+qemu -net user,hostfwd=tcp:127.0.0.1:6001-:6000,hostfwd=tcp:5555-::23 [...]
1309-+@end example
1310-+
1311- @item guestfwd=[tcp]:@var{server}:@var{port}-@var{dev}
1312- Forward guest TCP connections to the IP address @var{server} on port @var{port}
1313- to the character device @var{dev}. This option can be given multiple times.
1314---
1315-1.6.3.3
1316-
1317
1318=== removed file 'debian/patches/block_avoid_creating_too_large_iovecs_in_multiwrite_merge.patch'
1319--- debian/patches/block_avoid_creating_too_large_iovecs_in_multiwrite_merge.patch 2010-03-12 13:30:30 +0000
1320+++ debian/patches/block_avoid_creating_too_large_iovecs_in_multiwrite_merge.patch 1970-01-01 00:00:00 +0000
1321@@ -1,53 +0,0 @@
1322-From e2a305fb13ff0f5cf6ff805555aaa90a5ed5954c Mon Sep 17 00:00:00 2001
1323-From: Christoph Hellwig <hch@lst.de>
1324-Date: Tue, 26 Jan 2010 14:49:08 +0100
1325-Subject: [PATCH] block: avoid creating too large iovecs in multiwrite_merge
1326-
1327-If we go over the maximum number of iovecs support by syscall we get
1328-back EINVAL from the kernel which translate to I/O errors for the guest.
1329-
1330-Add a MAX_IOV defintion for platforms that don't have it. For now we use
1331-the same 1024 define that's used on Linux and various other platforms,
1332-but until the windows block backend implements some kind of vectored I/O
1333-it doesn't matter.
1334-
1335-Signed-off-by: Christoph Hellwig <hch@lst.de>
1336-Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
1337----
1338- block.c | 4 ++++
1339- qemu-common.h | 4 ++++
1340- 2 files changed, 8 insertions(+), 0 deletions(-)
1341-
1342-diff --git a/block.c b/block.c
1343-index 9c106a8..1919d19 100644
1344---- a/block.c
1345-+++ b/block.c
1346-@@ -1691,6 +1691,10 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
1347- merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
1348- }
1349-
1350-+ if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
1351-+ merge = 0;
1352-+ }
1353-+
1354- if (merge) {
1355- size_t size;
1356- QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
1357-diff --git a/qemu-common.h b/qemu-common.h
1358-index ae4f23b..b09f717 100644
1359---- a/qemu-common.h
1360-+++ b/qemu-common.h
1361-@@ -54,6 +54,10 @@ struct iovec {
1362- void *iov_base;
1363- size_t iov_len;
1364- };
1365-+/*
1366-+ * Use the same value as Linux for now.
1367-+ */
1368-+#define IOV_MAX 1024
1369- #else
1370- #include <sys/uio.h>
1371- #endif
1372---
1373-1.7.0.2
1374-
1375
1376=== modified file 'debian/patches/series'
1377--- debian/patches/series 2010-04-01 00:22:02 +0000
1378+++ debian/patches/series 2010-06-11 20:46:30 +0000
1379@@ -1,11 +1,3 @@
1380-05_improve-qemu-img-errors.patch
1381-0001-linux-user-adapt-uname-machine-to-emulated-CPU.patch
1382 0001-Fix-missing-symbols-in-.rel-.rela.plt-sections.patch
1383-Detect-and-use-GCC-atomic-builtins-for-locking.patch
1384-This-patch-adds-support-for-the-pselect-syscall-in-l.patch
1385-arm-host-fix-compiler-warning.patch
1386-better_describe_-net_options.patch
1387-block_avoid_creating_too_large_iovecs_in_multiwrite_merge.patch
1388 arm-higher-initrd-load-address.patch
1389 larger_default_ram_size.patch
1390-SDL-wrong-behaviour-of-caps-lock.patch
1391
1392=== modified file 'debian/rules'
1393--- debian/rules 2010-04-23 18:45:55 +0000
1394+++ debian/rules 2010-06-11 20:46:30 +0000
1395@@ -7,6 +7,17 @@
1396 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
1397 DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
1398
1399+ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
1400+ INSTALL_PROGRAM += -s
1401+endif
1402+
1403+# Handle DEB_BUILD_OPTIONS=parallel=N
1404+, := ,
1405+ifneq (,$(filter parallel=%,$(subst $(,), ,$(DEB_BUILD_OPTIONS))))
1406+ NUMJOBS := $(patsubst parallel=%,%,$(filter parallel=%,$(subst $(,), ,$(DEB_BUILD_OPTIONS))))
1407+ MAKEFLAGS += -j$(NUMJOBS)
1408+endif
1409+
1410 ifeq ($(DEB_HOST_ARCH_OS),linux)
1411 # Note: We differ from Debian here by favoring the pulseaudio driver, since that's default in Ubuntu.
1412 # Users override this when calling qemu by exporting the environment variable QEMU_AUDIO_DRV.
1413
1414=== modified file 'default-configs/sh4-softmmu.mak'
1415--- default-configs/sh4-softmmu.mak 2010-01-20 17:54:24 +0000
1416+++ default-configs/sh4-softmmu.mak 2010-06-11 20:46:30 +0000
1417@@ -2,3 +2,4 @@
1418
1419 CONFIG_USB_OHCI=y
1420 CONFIG_PTIMER=y
1421+CONFIG_ISA_MMIO=y
1422
1423=== modified file 'default-configs/sh4eb-softmmu.mak'
1424--- default-configs/sh4eb-softmmu.mak 2010-01-20 17:54:24 +0000
1425+++ default-configs/sh4eb-softmmu.mak 2010-06-11 20:46:30 +0000
1426@@ -2,3 +2,4 @@
1427
1428 CONFIG_USB_OHCI=y
1429 CONFIG_PTIMER=y
1430+CONFIG_ISA_MMIO=y
1431
1432=== modified file 'dyngen-exec.h'
1433--- dyngen-exec.h 2010-01-20 17:54:24 +0000
1434+++ dyngen-exec.h 2010-06-11 20:46:30 +0000
1435@@ -69,9 +69,9 @@
1436 #define AREG1 "r14"
1437 #define AREG2 "r15"
1438 #elif defined(__mips__)
1439-#define AREG0 "fp"
1440-#define AREG1 "s0"
1441-#define AREG2 "s1"
1442+#define AREG0 "s0"
1443+#define AREG1 "s1"
1444+#define AREG2 "fp"
1445 #elif defined(__sparc__)
1446 #ifdef CONFIG_SOLARIS
1447 #define AREG0 "g2"
1448
1449=== modified file 'hw/device-assignment.c'
1450--- hw/device-assignment.c 2010-01-21 16:22:13 +0000
1451+++ hw/device-assignment.c 2010-06-11 20:46:30 +0000
1452@@ -1311,77 +1311,6 @@
1453 }
1454 }
1455
1456-/* Option ROM header */
1457-struct option_rom_header {
1458- uint8_t signature[2];
1459- uint8_t rom_size;
1460- uint32_t entry_point;
1461- uint8_t reserved[17];
1462- uint16_t pci_header_offset;
1463- uint16_t expansion_header_offset;
1464-} __attribute__ ((packed));
1465-
1466-/* Option ROM PCI data structure */
1467-struct option_rom_pci_header {
1468- uint8_t signature[4];
1469- uint16_t vendor_id;
1470- uint16_t device_id;
1471- uint16_t vital_product_data_offset;
1472- uint16_t structure_length;
1473- uint8_t structure_revision;
1474- uint8_t class_code[3];
1475- uint16_t image_length;
1476- uint16_t image_revision;
1477- uint8_t code_type;
1478- uint8_t indicator;
1479- uint16_t reserved;
1480-} __attribute__ ((packed));
1481-
1482-/*
1483- * Scan the list of Option ROMs at roms. If a suitable Option ROM is found,
1484- * allocate a ram space and copy it there. Then return its size aligned to
1485- * both 2KB and target page size.
1486- */
1487-#define OPTION_ROM_ALIGN(x) (((x) + 2047) & ~2047)
1488-static void scan_option_rom(const char *name, uint8_t devfn, void *roms)
1489-{
1490- int i, size;
1491- uint8_t csum;
1492- struct option_rom_header *rom;
1493- struct option_rom_pci_header *pcih;
1494-
1495- rom = roms;
1496-
1497- for ( ; ; ) {
1498- /* Invalid signature means we're out of option ROMs. */
1499- if (strncmp((char *)rom->signature, "\x55\xaa", 2) ||
1500- (rom->rom_size == 0))
1501- break;
1502-
1503- size = rom->rom_size * 512;
1504- /* Invalid checksum means we're out of option ROMs. */
1505- csum = 0;
1506- for (i = 0; i < size; i++)
1507- csum += ((uint8_t *)rom)[i];
1508- if (csum != 0)
1509- break;
1510-
1511- /* Check the PCI header (if any) for a match. */
1512- pcih = (struct option_rom_pci_header *)
1513- ((char *)rom + rom->pci_header_offset);
1514- if ((rom->pci_header_offset != 0) &&
1515- !strncmp((char *)pcih->signature, "PCIR", 4))
1516- goto found;
1517-
1518- rom = (struct option_rom_header *)((char *)rom + size);
1519- }
1520- return;
1521-
1522- found:
1523- rom_add_blob(name ? name : "assigned device", rom, size, 0);
1524- return;
1525-}
1526-
1527 /*
1528 * Scan the assigned devices for the devices that have an option ROM, and then
1529 * load the corresponding ROM data to RAM. If an error occurs while loading an
1530@@ -1445,9 +1374,5 @@
1531 size, PROT_READ);
1532 }
1533
1534- if (!dev->dev.qdev.hotplugged) {
1535- /* Scan the buffer for suitable ROMs and increase the offset */
1536- scan_option_rom(dev->dev.qdev.id, dev->dev.devfn, buf);
1537- }
1538 free(buf);
1539 }
1540
1541=== modified file 'hw/fdc.c'
1542--- hw/fdc.c 2010-01-20 17:54:24 +0000
1543+++ hw/fdc.c 2010-06-11 20:46:30 +0000
1544@@ -1860,8 +1860,12 @@
1545 ISADevice *dev;
1546
1547 dev = isa_create("isa-fdc");
1548- qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
1549- qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
1550+ if (fds[0]) {
1551+ qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
1552+ }
1553+ if (fds[1]) {
1554+ qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
1555+ }
1556 if (qdev_init(&dev->qdev) < 0)
1557 return NULL;
1558 return &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
1559@@ -1879,8 +1883,12 @@
1560 sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
1561 fdctrl = &sys->state;
1562 fdctrl->dma_chann = dma_chann; /* FIXME */
1563- qdev_prop_set_drive(dev, "driveA", fds[0]);
1564- qdev_prop_set_drive(dev, "driveB", fds[1]);
1565+ if (fds[0]) {
1566+ qdev_prop_set_drive(dev, "driveA", fds[0]);
1567+ }
1568+ if (fds[1]) {
1569+ qdev_prop_set_drive(dev, "driveB", fds[1]);
1570+ }
1571 qdev_init_nofail(dev);
1572 sysbus_connect_irq(&sys->busdev, 0, irq);
1573 sysbus_mmio_map(&sys->busdev, 0, mmio_base);
1574@@ -1896,7 +1904,9 @@
1575 fdctrl_t *fdctrl;
1576
1577 dev = qdev_create(NULL, "SUNW,fdtwo");
1578- qdev_prop_set_drive(dev, "drive", fds[0]);
1579+ if (fds[0]) {
1580+ qdev_prop_set_drive(dev, "drive", fds[0]);
1581+ }
1582 qdev_init_nofail(dev);
1583 sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
1584 fdctrl = &sys->state;
1585
1586=== modified file 'hw/fw_cfg.c'
1587--- hw/fw_cfg.c 2010-01-21 16:22:13 +0000
1588+++ hw/fw_cfg.c 2010-06-11 20:46:30 +0000
1589@@ -179,7 +179,7 @@
1590
1591 static void put_unused(QEMUFile *f, void *pv, size_t size)
1592 {
1593- fprintf(stderr, "uint32_as_uint16 is only used for backward compatibilty.\n");
1594+ fprintf(stderr, "uint32_as_uint16 is only used for backward compatibility.\n");
1595 fprintf(stderr, "This functions shouldn't be called.\n");
1596 }
1597
1598
1599=== modified file 'hw/ide/cmd646.c'
1600--- hw/ide/cmd646.c 2010-01-20 17:54:24 +0000
1601+++ hw/ide/cmd646.c 2010-06-11 20:46:30 +0000
1602@@ -70,11 +70,7 @@
1603
1604 static PCIIDEState *pci_from_bm(BMDMAState *bm)
1605 {
1606- if (bm->unit == 0) {
1607- return container_of(bm, PCIIDEState, bmdma[0]);
1608- } else {
1609- return container_of(bm, PCIIDEState, bmdma[1]);
1610- }
1611+ return bm->pci_dev;
1612 }
1613
1614 static uint32_t bmdma_readb(void *opaque, uint32_t addr)
1615@@ -145,6 +141,7 @@
1616 BMDMAState *bm = &d->bmdma[i];
1617 d->bus[i].bmdma = bm;
1618 bm->bus = d->bus+i;
1619+ bm->pci_dev = d;
1620 qemu_add_vm_change_state_handler(ide_dma_restart_cb, bm);
1621
1622 register_ioport_write(addr, 1, 1, bmdma_cmd_writeb, bm);
1623
1624=== modified file 'hw/ide/internal.h'
1625--- hw/ide/internal.h 2010-02-26 16:26:00 +0000
1626+++ hw/ide/internal.h 2010-06-11 20:46:30 +0000
1627@@ -481,6 +481,7 @@
1628 uint8_t status;
1629 uint32_t addr;
1630
1631+ struct PCIIDEState *pci_dev;
1632 IDEBus *bus;
1633 /* current transfer state */
1634 uint32_t cur_addr;
1635
1636=== modified file 'hw/ide/piix.c'
1637--- hw/ide/piix.c 2010-01-20 17:54:24 +0000
1638+++ hw/ide/piix.c 2010-06-11 20:46:30 +0000
1639@@ -78,6 +78,7 @@
1640 BMDMAState *bm = &d->bmdma[i];
1641 d->bus[i].bmdma = bm;
1642 bm->bus = d->bus+i;
1643+ bm->pci_dev = d;
1644 qemu_add_vm_change_state_handler(ide_dma_restart_cb, bm);
1645
1646 register_ioport_write(addr, 1, 1, bmdma_cmd_writeb, bm);
1647
1648=== modified file 'hw/lsi53c895a.c'
1649--- hw/lsi53c895a.c 2010-01-20 17:54:24 +0000
1650+++ hw/lsi53c895a.c 2010-06-11 20:46:30 +0000
1651@@ -173,11 +173,15 @@
1652 /* Flag set if this is a tagged command. */
1653 #define LSI_TAG_VALID (1 << 16)
1654
1655-typedef struct {
1656+typedef struct lsi_request {
1657 uint32_t tag;
1658+ SCSIDevice *dev;
1659+ uint32_t dma_len;
1660+ uint8_t *dma_buf;
1661 uint32_t pending;
1662 int out;
1663-} lsi_queue;
1664+ QTAILQ_ENTRY(lsi_request) next;
1665+} lsi_request;
1666
1667 typedef struct {
1668 PCIDevice dev;
1669@@ -198,16 +202,13 @@
1670 * 3 if a DMA operation is in progress. */
1671 int waiting;
1672 SCSIBus bus;
1673- SCSIDevice *current_dev;
1674+ SCSIDevice *select_dev;
1675 int current_lun;
1676 /* The tag is a combination of the device ID and the SCSI tag. */
1677- uint32_t current_tag;
1678- uint32_t current_dma_len;
1679+ uint32_t select_tag;
1680 int command_complete;
1681- uint8_t *dma_buf;
1682- lsi_queue *queue;
1683- int queue_len;
1684- int active_commands;
1685+ QTAILQ_HEAD(, lsi_request) queue;
1686+ lsi_request *current;
1687
1688 uint32_t dsa;
1689 uint32_t temp;
1690@@ -370,7 +371,7 @@
1691 static uint8_t lsi_reg_readb(LSIState *s, int offset);
1692 static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val);
1693 static void lsi_execute_script(LSIState *s);
1694-static void lsi_reselect(LSIState *s, uint32_t tag);
1695+static void lsi_reselect(LSIState *s, lsi_request *p);
1696
1697 static inline uint32_t read_dword(LSIState *s, uint32_t addr)
1698 {
1699@@ -391,9 +392,9 @@
1700
1701 static void lsi_update_irq(LSIState *s)
1702 {
1703- int i;
1704 int level;
1705 static int last_level;
1706+ lsi_request *p;
1707
1708 /* It's unclear whether the DIP/SIP bits should be cleared when the
1709 Interrupt Status Registers are cleared or when istat0 is read.
1710@@ -427,9 +428,9 @@
1711 if (!level && lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON)) {
1712 DPRINTF("Handled IRQs & disconnected, looking for pending "
1713 "processes\n");
1714- for (i = 0; i < s->active_commands; i++) {
1715- if (s->queue[i].pending) {
1716- lsi_reselect(s, s->queue[i].tag);
1717+ QTAILQ_FOREACH(p, &s->queue, next) {
1718+ if (p->pending) {
1719+ lsi_reselect(s, p);
1720 break;
1721 }
1722 }
1723@@ -508,15 +509,16 @@
1724 uint32_t count;
1725 target_phys_addr_t addr;
1726
1727- if (!s->current_dma_len) {
1728+ assert(s->current);
1729+ if (!s->current->dma_len) {
1730 /* Wait until data is available. */
1731 DPRINTF("DMA no data available\n");
1732 return;
1733 }
1734
1735 count = s->dbc;
1736- if (count > s->current_dma_len)
1737- count = s->current_dma_len;
1738+ if (count > s->current->dma_len)
1739+ count = s->current->dma_len;
1740
1741 addr = s->dnad;
1742 /* both 40 and Table Indirect 64-bit DMAs store upper bits in dnad64 */
1743@@ -532,29 +534,29 @@
1744 s->dnad += count;
1745 s->dbc -= count;
1746
1747- if (s->dma_buf == NULL) {
1748- s->dma_buf = s->current_dev->info->get_buf(s->current_dev,
1749- s->current_tag);
1750+ if (s->current->dma_buf == NULL) {
1751+ s->current->dma_buf = s->current->dev->info->get_buf(s->current->dev,
1752+ s->current->tag);
1753 }
1754
1755 /* ??? Set SFBR to first data byte. */
1756 if (out) {
1757- cpu_physical_memory_read(addr, s->dma_buf, count);
1758+ cpu_physical_memory_read(addr, s->current->dma_buf, count);
1759 } else {
1760- cpu_physical_memory_write(addr, s->dma_buf, count);
1761+ cpu_physical_memory_write(addr, s->current->dma_buf, count);
1762 }
1763- s->current_dma_len -= count;
1764- if (s->current_dma_len == 0) {
1765- s->dma_buf = NULL;
1766+ s->current->dma_len -= count;
1767+ if (s->current->dma_len == 0) {
1768+ s->current->dma_buf = NULL;
1769 if (out) {
1770 /* Write the data. */
1771- s->current_dev->info->write_data(s->current_dev, s->current_tag);
1772+ s->current->dev->info->write_data(s->current->dev, s->current->tag);
1773 } else {
1774 /* Request any remaining data. */
1775- s->current_dev->info->read_data(s->current_dev, s->current_tag);
1776+ s->current->dev->info->read_data(s->current->dev, s->current->tag);
1777 }
1778 } else {
1779- s->dma_buf += count;
1780+ s->current->dma_buf += count;
1781 lsi_resume_script(s);
1782 }
1783 }
1784@@ -563,15 +565,14 @@
1785 /* Add a command to the queue. */
1786 static void lsi_queue_command(LSIState *s)
1787 {
1788- lsi_queue *p;
1789+ lsi_request *p = s->current;
1790
1791 DPRINTF("Queueing tag=0x%x\n", s->current_tag);
1792- if (s->queue_len == s->active_commands) {
1793- s->queue_len++;
1794- s->queue = qemu_realloc(s->queue, s->queue_len * sizeof(lsi_queue));
1795- }
1796- p = &s->queue[s->active_commands++];
1797- p->tag = s->current_tag;
1798+ assert(s->current != NULL);
1799+ assert(s->current->dma_len == 0);
1800+ QTAILQ_INSERT_TAIL(&s->queue, s->current, next);
1801+ s->current = NULL;
1802+
1803 p->pending = 0;
1804 p->out = (s->sstat1 & PHASE_MASK) == PHASE_DO;
1805 }
1806@@ -588,45 +589,29 @@
1807 }
1808
1809 /* Perform reselection to continue a command. */
1810-static void lsi_reselect(LSIState *s, uint32_t tag)
1811+static void lsi_reselect(LSIState *s, lsi_request *p)
1812 {
1813- lsi_queue *p;
1814- int n;
1815 int id;
1816
1817- p = NULL;
1818- for (n = 0; n < s->active_commands; n++) {
1819- p = &s->queue[n];
1820- if (p->tag == tag)
1821- break;
1822- }
1823- if (n == s->active_commands) {
1824- BADF("Reselected non-existant command tag=0x%x\n", tag);
1825- return;
1826- }
1827- id = (tag >> 8) & 0xf;
1828+ assert(s->current == NULL);
1829+ QTAILQ_REMOVE(&s->queue, p, next);
1830+ s->current = p;
1831+
1832+ id = (p->tag >> 8) & 0xf;
1833 s->ssid = id | 0x80;
1834 /* LSI53C700 Family Compatibility, see LSI53C895A 4-73 */
1835 if (!s->dcntl & LSI_DCNTL_COM) {
1836 s->sfbr = 1 << (id & 0x7);
1837 }
1838 DPRINTF("Reselected target %d\n", id);
1839- s->current_dev = s->bus.devs[id];
1840- s->current_tag = tag;
1841 s->scntl1 |= LSI_SCNTL1_CON;
1842 lsi_set_phase(s, PHASE_MI);
1843 s->msg_action = p->out ? 2 : 3;
1844- s->current_dma_len = p->pending;
1845- s->dma_buf = NULL;
1846+ s->current->dma_len = p->pending;
1847 lsi_add_msg_byte(s, 0x80);
1848- if (s->current_tag & LSI_TAG_VALID) {
1849+ if (s->current->tag & LSI_TAG_VALID) {
1850 lsi_add_msg_byte(s, 0x20);
1851- lsi_add_msg_byte(s, tag & 0xff);
1852- }
1853-
1854- s->active_commands--;
1855- if (n != s->active_commands) {
1856- s->queue[n] = s->queue[s->active_commands];
1857+ lsi_add_msg_byte(s, p->tag & 0xff);
1858 }
1859
1860 if (lsi_irq_on_rsl(s)) {
1861@@ -638,10 +623,9 @@
1862 the device was reselected, nonzero if the IO is deferred. */
1863 static int lsi_queue_tag(LSIState *s, uint32_t tag, uint32_t arg)
1864 {
1865- lsi_queue *p;
1866- int i;
1867- for (i = 0; i < s->active_commands; i++) {
1868- p = &s->queue[i];
1869+ lsi_request *p;
1870+
1871+ QTAILQ_FOREACH(p, &s->queue, next) {
1872 if (p->tag == tag) {
1873 if (p->pending) {
1874 BADF("Multiple IO pending for tag %d\n", tag);
1875@@ -656,10 +640,10 @@
1876 (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) &&
1877 !(s->istat0 & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) {
1878 /* Reselect device. */
1879- lsi_reselect(s, tag);
1880+ lsi_reselect(s, p);
1881 return 0;
1882 } else {
1883- DPRINTF("Queueing IO tag=0x%x\n", tag);
1884+ DPRINTF("Queueing IO tag=0x%x\n", tag);
1885 p->pending = arg;
1886 return 1;
1887 }
1888@@ -687,11 +671,15 @@
1889 } else {
1890 lsi_set_phase(s, PHASE_ST);
1891 }
1892+
1893+ qemu_free(s->current);
1894+ s->current = NULL;
1895+
1896 lsi_resume_script(s);
1897 return;
1898 }
1899
1900- if (s->waiting == 1 || tag != s->current_tag ||
1901+ if (s->waiting == 1 || !s->current || tag != s->current->tag ||
1902 (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
1903 if (lsi_queue_tag(s, tag, arg))
1904 return;
1905@@ -699,7 +687,7 @@
1906
1907 /* host adapter (re)connected */
1908 DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg);
1909- s->current_dma_len = arg;
1910+ s->current->dma_len = arg;
1911 s->command_complete = 1;
1912 if (!s->waiting)
1913 return;
1914@@ -721,14 +709,20 @@
1915 cpu_physical_memory_read(s->dnad, buf, s->dbc);
1916 s->sfbr = buf[0];
1917 s->command_complete = 0;
1918- n = s->current_dev->info->send_command(s->current_dev, s->current_tag, buf,
1919- s->current_lun);
1920+
1921+ assert(s->current == NULL);
1922+ s->current = qemu_mallocz(sizeof(lsi_request));
1923+ s->current->tag = s->select_tag;
1924+ s->current->dev = s->select_dev;
1925+
1926+ n = s->current->dev->info->send_command(s->current->dev, s->current->tag, buf,
1927+ s->current_lun);
1928 if (n > 0) {
1929 lsi_set_phase(s, PHASE_DI);
1930- s->current_dev->info->read_data(s->current_dev, s->current_tag);
1931+ s->current->dev->info->read_data(s->current->dev, s->current->tag);
1932 } else if (n < 0) {
1933 lsi_set_phase(s, PHASE_DO);
1934- s->current_dev->info->write_data(s->current_dev, s->current_tag);
1935+ s->current->dev->info->write_data(s->current->dev, s->current->tag);
1936 }
1937
1938 if (!s->command_complete) {
1939@@ -851,16 +845,16 @@
1940 }
1941 break;
1942 case 0x20: /* SIMPLE queue */
1943- s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1944+ s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1945 DPRINTF("SIMPLE queue tag=0x%x\n", s->current_tag & 0xff);
1946 break;
1947 case 0x21: /* HEAD of queue */
1948 BADF("HEAD queue not implemented\n");
1949- s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1950+ s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1951 break;
1952 case 0x22: /* ORDERED queue */
1953 BADF("ORDERED queue not implemented\n");
1954- s->current_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1955+ s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
1956 break;
1957 default:
1958 if ((msg & 0x80) == 0) {
1959@@ -905,17 +899,17 @@
1960
1961 static void lsi_wait_reselect(LSIState *s)
1962 {
1963- int i;
1964+ lsi_request *p;
1965+
1966 DPRINTF("Wait Reselect\n");
1967- if (s->current_dma_len)
1968- BADF("Reselect with pending DMA\n");
1969- for (i = 0; i < s->active_commands; i++) {
1970- if (s->queue[i].pending) {
1971- lsi_reselect(s, s->queue[i].tag);
1972+
1973+ QTAILQ_FOREACH(p, &s->queue, next) {
1974+ if (p->pending) {
1975+ lsi_reselect(s, p);
1976 break;
1977 }
1978 }
1979- if (s->current_dma_len == 0) {
1980+ if (s->current == NULL) {
1981 s->waiting = 1;
1982 }
1983 }
1984@@ -1093,8 +1087,8 @@
1985 /* ??? Linux drivers compain when this is set. Maybe
1986 it only applies in low-level mode (unimplemented).
1987 lsi_script_scsi_interrupt(s, LSI_SIST0_CMP, 0); */
1988- s->current_dev = s->bus.devs[id];
1989- s->current_tag = id << 8;
1990+ s->select_dev = s->bus.devs[id];
1991+ s->select_tag = id << 8;
1992 s->scntl1 |= LSI_SCNTL1_CON;
1993 if (insn & (1 << 3)) {
1994 s->socl |= LSI_SOCL_ATN;
1995@@ -2006,9 +2000,11 @@
1996 {
1997 LSIState *s = opaque;
1998
1999- assert(s->dma_buf == NULL);
2000- assert(s->current_dma_len == 0);
2001- assert(s->active_commands == 0);
2002+ if (s->current) {
2003+ assert(s->current->dma_buf == NULL);
2004+ assert(s->current->dma_len == 0);
2005+ }
2006+ assert(QTAILQ_EMPTY(&s->queue));
2007 }
2008
2009 static const VMStateDescription vmstate_lsi_scsi = {
2010@@ -2101,8 +2097,6 @@
2011 cpu_unregister_io_memory(s->mmio_io_addr);
2012 cpu_unregister_io_memory(s->ram_io_addr);
2013
2014- qemu_free(s->queue);
2015-
2016 return 0;
2017 }
2018
2019@@ -2138,9 +2132,7 @@
2020 PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_mmio_mapfunc);
2021 pci_register_bar((struct PCIDevice *)s, 2, 0x2000,
2022 PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_ram_mapfunc);
2023- s->queue = qemu_malloc(sizeof(lsi_queue));
2024- s->queue_len = 1;
2025- s->active_commands = 0;
2026+ QTAILQ_INIT(&s->queue);
2027
2028 lsi_soft_reset(s);
2029
2030
2031=== modified file 'hw/scsi-disk.c'
2032--- hw/scsi-disk.c 2010-02-26 16:26:00 +0000
2033+++ hw/scsi-disk.c 2010-06-11 20:46:30 +0000
2034@@ -434,7 +434,9 @@
2035 memcpy(&outbuf[16], "QEMU HARDDISK ", 16);
2036 }
2037 memcpy(&outbuf[8], "QEMU ", 8);
2038- memcpy(&outbuf[32], s->version ? s->version : QEMU_VERSION, 4);
2039+ memset(&outbuf[32], 0, 4);
2040+ memcpy(&outbuf[32], s->version ? s->version : QEMU_VERSION,
2041+ MIN(4, strlen(s->version ? s->version : QEMU_VERSION)));
2042 /* Identify device as SCSI-3 rev 1.
2043 Some later commands are also implemented. */
2044 outbuf[2] = 3;
2045
2046=== modified file 'hw/sh7750.c'
2047--- hw/sh7750.c 2010-01-20 17:54:24 +0000
2048+++ hw/sh7750.c 2010-06-11 20:46:30 +0000
2049@@ -396,8 +396,11 @@
2050 portb_changed(s, temp);
2051 return;
2052 case SH7750_MMUCR_A7:
2053- s->cpu->mmucr = mem_value;
2054- return;
2055+ if (mem_value & MMUCR_TI) {
2056+ cpu_sh4_invalidate_tlb(s->cpu);
2057+ }
2058+ s->cpu->mmucr = mem_value & ~MMUCR_TI;
2059+ return;
2060 case SH7750_PTEH_A7:
2061 /* If asid changes, clear all registered tlb entries. */
2062 if ((s->cpu->pteh & 0xff) != (mem_value & 0xff))
2063
2064=== modified file 'hw/sh_pci.c'
2065--- hw/sh_pci.c 2010-01-20 17:54:24 +0000
2066+++ hw/sh_pci.c 2010-06-11 20:46:30 +0000
2067@@ -47,10 +47,15 @@
2068 pcic->par = val;
2069 break;
2070 case 0x1c4:
2071- pcic->mbr = val;
2072+ pcic->mbr = val & 0xff000001;
2073 break;
2074 case 0x1c8:
2075- pcic->iobr = val;
2076+ if ((val & 0xfffc0000) != (pcic->iobr & 0xfffc0000)) {
2077+ cpu_register_physical_memory(pcic->iobr & 0xfffc0000, 0x40000,
2078+ IO_MEM_UNASSIGNED);
2079+ pcic->iobr = val & 0xfffc0001;
2080+ isa_mmio_init(pcic->iobr & 0xfffc0000, 0x40000);
2081+ }
2082 break;
2083 case 0x220:
2084 pci_data_write(pcic->bus, pcic->par, val, 4);
2085@@ -66,89 +71,16 @@
2086 return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
2087 case 0x1c0:
2088 return pcic->par;
2089+ case 0x1c4:
2090+ return pcic->mbr;
2091+ case 0x1c8:
2092+ return pcic->iobr;
2093 case 0x220:
2094 return pci_data_read(pcic->bus, pcic->par, 4);
2095 }
2096 return 0;
2097 }
2098
2099-static void sh_pci_data_write (SHPCIC *pcic, target_phys_addr_t addr,
2100- uint32_t val, int size)
2101-{
2102- pci_data_write(pcic->bus, addr + pcic->mbr, val, size);
2103-}
2104-
2105-static uint32_t sh_pci_mem_read (SHPCIC *pcic, target_phys_addr_t addr,
2106- int size)
2107-{
2108- return pci_data_read(pcic->bus, addr + pcic->mbr, size);
2109-}
2110-
2111-static void sh_pci_writeb (void *p, target_phys_addr_t addr, uint32_t val)
2112-{
2113- sh_pci_data_write(p, addr, val, 1);
2114-}
2115-
2116-static void sh_pci_writew (void *p, target_phys_addr_t addr, uint32_t val)
2117-{
2118- sh_pci_data_write(p, addr, val, 2);
2119-}
2120-
2121-static void sh_pci_writel (void *p, target_phys_addr_t addr, uint32_t val)
2122-{
2123- sh_pci_data_write(p, addr, val, 4);
2124-}
2125-
2126-static uint32_t sh_pci_readb (void *p, target_phys_addr_t addr)
2127-{
2128- return sh_pci_mem_read(p, addr, 1);
2129-}
2130-
2131-static uint32_t sh_pci_readw (void *p, target_phys_addr_t addr)
2132-{
2133- return sh_pci_mem_read(p, addr, 2);
2134-}
2135-
2136-static uint32_t sh_pci_readl (void *p, target_phys_addr_t addr)
2137-{
2138- return sh_pci_mem_read(p, addr, 4);
2139-}
2140-
2141-static int sh_pci_addr2port(SHPCIC *pcic, target_phys_addr_t addr)
2142-{
2143- return addr + pcic->iobr;
2144-}
2145-
2146-static void sh_pci_outb (void *p, target_phys_addr_t addr, uint32_t val)
2147-{
2148- cpu_outb(sh_pci_addr2port(p, addr), val);
2149-}
2150-
2151-static void sh_pci_outw (void *p, target_phys_addr_t addr, uint32_t val)
2152-{
2153- cpu_outw(sh_pci_addr2port(p, addr), val);
2154-}
2155-
2156-static void sh_pci_outl (void *p, target_phys_addr_t addr, uint32_t val)
2157-{
2158- cpu_outl(sh_pci_addr2port(p, addr), val);
2159-}
2160-
2161-static uint32_t sh_pci_inb (void *p, target_phys_addr_t addr)
2162-{
2163- return cpu_inb(sh_pci_addr2port(p, addr));
2164-}
2165-
2166-static uint32_t sh_pci_inw (void *p, target_phys_addr_t addr)
2167-{
2168- return cpu_inw(sh_pci_addr2port(p, addr));
2169-}
2170-
2171-static uint32_t sh_pci_inl (void *p, target_phys_addr_t addr)
2172-{
2173- return cpu_inl(sh_pci_addr2port(p, addr));
2174-}
2175-
2176 typedef struct {
2177 CPUReadMemoryFunc * const r[3];
2178 CPUWriteMemoryFunc * const w[3];
2179@@ -159,21 +91,11 @@
2180 { NULL, NULL, sh_pci_reg_write },
2181 };
2182
2183-static MemOp sh_pci_mem = {
2184- { sh_pci_readb, sh_pci_readw, sh_pci_readl },
2185- { sh_pci_writeb, sh_pci_writew, sh_pci_writel },
2186-};
2187-
2188-static MemOp sh_pci_iop = {
2189- { sh_pci_inb, sh_pci_inw, sh_pci_inl },
2190- { sh_pci_outb, sh_pci_outw, sh_pci_outl },
2191-};
2192-
2193 PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
2194 void *opaque, int devfn_min, int nirq)
2195 {
2196 SHPCIC *p;
2197- int mem, reg, iop;
2198+ int reg;
2199
2200 p = qemu_mallocz(sizeof(SHPCIC));
2201 p->bus = pci_register_bus(NULL, "pci",
2202@@ -182,14 +104,11 @@
2203 p->dev = pci_register_device(p->bus, "SH PCIC", sizeof(PCIDevice),
2204 -1, NULL, NULL);
2205 reg = cpu_register_io_memory(sh_pci_reg.r, sh_pci_reg.w, p);
2206- iop = cpu_register_io_memory(sh_pci_iop.r, sh_pci_iop.w, p);
2207- mem = cpu_register_io_memory(sh_pci_mem.r, sh_pci_mem.w, p);
2208 cpu_register_physical_memory(0x1e200000, 0x224, reg);
2209- cpu_register_physical_memory(0x1e240000, 0x40000, iop);
2210- cpu_register_physical_memory(0x1d000000, 0x1000000, mem);
2211 cpu_register_physical_memory(0xfe200000, 0x224, reg);
2212- cpu_register_physical_memory(0xfe240000, 0x40000, iop);
2213- cpu_register_physical_memory(0xfd000000, 0x1000000, mem);
2214+
2215+ p->iobr = 0xfe240000;
2216+ isa_mmio_init(p->iobr, 0x40000);
2217
2218 pci_config_set_vendor_id(p->dev->config, PCI_VENDOR_ID_HITACHI);
2219 pci_config_set_device_id(p->dev->config, PCI_DEVICE_ID_HITACHI_SH7751R);
2220
2221=== modified file 'hw/usb-uhci.c'
2222--- hw/usb-uhci.c 2010-01-20 17:54:24 +0000
2223+++ hw/usb-uhci.c 2010-06-11 20:46:30 +0000
2224@@ -677,9 +677,6 @@
2225
2226 ret = async->packet.len;
2227
2228- if (td->ctrl & TD_CTRL_IOC)
2229- *int_mask |= 0x01;
2230-
2231 if (td->ctrl & TD_CTRL_IOS)
2232 td->ctrl &= ~TD_CTRL_ACTIVE;
2233
2234@@ -693,6 +690,8 @@
2235 here. The docs are somewhat unclear, but win2k relies on this
2236 behavior. */
2237 td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);
2238+ if (td->ctrl & TD_CTRL_IOC)
2239+ *int_mask |= 0x01;
2240
2241 if (pid == USB_TOKEN_IN) {
2242 if (len > max_len) {
2243@@ -750,6 +749,8 @@
2244 if (err == 0) {
2245 td->ctrl &= ~TD_CTRL_ACTIVE;
2246 s->status |= UHCI_STS_USBERR;
2247+ if (td->ctrl & TD_CTRL_IOC)
2248+ *int_mask |= 0x01;
2249 uhci_update_irq(s);
2250 }
2251 }
2252
2253=== modified file 'json-parser.c'
2254--- json-parser.c 2010-02-26 16:26:00 +0000
2255+++ json-parser.c 2010-06-11 20:46:30 +0000
2256@@ -266,7 +266,7 @@
2257
2258 peek = qlist_peek(working);
2259 key = parse_value(ctxt, &working, ap);
2260- if (qobject_type(key) != QTYPE_QSTRING) {
2261+ if (!key || qobject_type(key) != QTYPE_QSTRING) {
2262 parse_error(ctxt, peek, "key is not a string in object");
2263 goto out;
2264 }
2265
2266=== modified file 'linux-user/main.c'
2267--- linux-user/main.c 2010-01-20 17:54:24 +0000
2268+++ linux-user/main.c 2010-06-11 20:46:30 +0000
2269@@ -2684,7 +2684,7 @@
2270 #endif
2271 #elif defined(TARGET_PPC)
2272 #ifdef TARGET_PPC64
2273- cpu_model = "970";
2274+ cpu_model = "970fx";
2275 #else
2276 cpu_model = "750";
2277 #endif
2278
2279=== modified file 'net.c'
2280--- net.c 2010-02-26 16:26:00 +0000
2281+++ net.c 2010-06-11 20:46:30 +0000
2282@@ -1187,26 +1187,6 @@
2283 qemu_del_vlan_client(vc);
2284 }
2285
2286-void net_set_boot_mask(int net_boot_mask)
2287-{
2288- int i;
2289-
2290- /* Only the first four NICs may be bootable */
2291- net_boot_mask = net_boot_mask & 0xF;
2292-
2293- for (i = 0; i < nb_nics; i++) {
2294- if (net_boot_mask & (1 << i)) {
2295- nd_table[i].bootable = 1;
2296- net_boot_mask &= ~(1 << i);
2297- }
2298- }
2299-
2300- if (net_boot_mask) {
2301- fprintf(stderr, "Cannot boot from non-existent NIC\n");
2302- exit(1);
2303- }
2304-}
2305-
2306 void do_info_network(Monitor *mon)
2307 {
2308 VLANState *vlan;
2309
2310=== modified file 'net.h'
2311--- net.h 2010-02-26 16:26:00 +0000
2312+++ net.h 2010-06-11 20:46:30 +0000
2313@@ -163,7 +163,6 @@
2314 int net_init_clients(void);
2315 void net_check_clients(void);
2316 void net_cleanup(void);
2317-void net_set_boot_mask(int boot_mask);
2318 void net_host_device_add(Monitor *mon, const QDict *qdict);
2319 void net_host_device_remove(Monitor *mon, const QDict *qdict);
2320
2321
2322=== modified file 'qemu-char.c'
2323--- qemu-char.c 2010-02-26 16:26:00 +0000
2324+++ qemu-char.c 2010-06-11 20:46:30 +0000
2325@@ -2317,8 +2317,7 @@
2326 qemu_opt_set(opts, "backend", "udp");
2327 if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port, &pos) < 2) {
2328 host[0] = 0;
2329- if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
2330- fprintf(stderr, "udp #1\n");
2331+ if (sscanf(p, ":%32[^@,]%n", port, &pos) < 1) {
2332 goto fail;
2333 }
2334 }
2335@@ -2329,7 +2328,6 @@
2336 if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
2337 host[0] = 0;
2338 if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
2339- fprintf(stderr, "udp #2\n");
2340 goto fail;
2341 }
2342 }
2343@@ -2357,7 +2355,6 @@
2344 }
2345
2346 fail:
2347- fprintf(stderr, "%s: fail on \"%s\"\n", __FUNCTION__, filename);
2348 qemu_opts_del(opts);
2349 return NULL;
2350 }
2351
2352=== modified file 'qemu-common.h'
2353--- qemu-common.h 2010-02-26 16:26:00 +0000
2354+++ qemu-common.h 2010-06-11 20:46:30 +0000
2355@@ -54,6 +54,10 @@
2356 void *iov_base;
2357 size_t iov_len;
2358 };
2359+/*
2360+ * Use the same value as Linux for now.
2361+ */
2362+#define IOV_MAX 1024
2363 #else
2364 #include <sys/uio.h>
2365 #endif
2366
2367=== modified file 'qemu-kvm.c'
2368--- qemu-kvm.c 2010-02-26 16:26:00 +0000
2369+++ qemu-kvm.c 2010-06-11 20:46:30 +0000
2370@@ -444,7 +444,8 @@
2371 r = kvm_vm_ioctl(kvm_state, KVM_CREATE_VCPU, id);
2372 if (r < 0) {
2373 fprintf(stderr, "kvm_create_vcpu: %m\n");
2374- return;
2375+ fprintf(stderr, "Failed to create vCPU. Check the -smp parameter.\n");
2376+ goto err;
2377 }
2378
2379 env->kvm_fd = r;
2380@@ -466,6 +467,9 @@
2381 return;
2382 err_fd:
2383 close(env->kvm_fd);
2384+ err:
2385+ /* We're no good with semi-broken states. */
2386+ abort();
2387 }
2388
2389 static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id)
2390
2391=== modified file 'qemu-options.hx'
2392--- qemu-options.hx 2010-02-26 16:26:00 +0000
2393+++ qemu-options.hx 2010-06-11 20:46:30 +0000
2394@@ -969,7 +969,7 @@
2395
2396 @example
2397 # on the host
2398-qemu -net user,hostfwd=tcp:5555::23 [...]
2399+qemu -net user,hostfwd=tcp::5555-:23 [...]
2400 telnet localhost 5555
2401 @end example
2402
2403
2404=== modified file 'target-i386/translate.c'
2405--- target-i386/translate.c 2010-01-21 16:22:13 +0000
2406+++ target-i386/translate.c 2010-06-11 20:46:30 +0000
2407@@ -2047,8 +2047,8 @@
2408 gen_op_movl_A0_im(disp);
2409 }
2410 }
2411- /* XXX: index == 4 is always invalid */
2412- if (havesib && (index != 4 || scale != 0)) {
2413+ /* index == 4 means no index */
2414+ if (havesib && (index != 4)) {
2415 #ifdef TARGET_X86_64
2416 if (s->aflag == 2) {
2417 gen_op_addq_A0_reg_sN(scale, index);
2418@@ -3165,11 +3165,16 @@
2419 case 0x1e7: /* movntdq */
2420 case 0x02b: /* movntps */
2421 case 0x12b: /* movntps */
2422+ if (mod == 3)
2423+ goto illegal_op;
2424+ gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
2425+ gen_sto_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg]));
2426+ break;
2427 case 0x3f0: /* lddqu */
2428 if (mod == 3)
2429 goto illegal_op;
2430 gen_lea_modrm(s, modrm, &reg_addr, &offset_addr);
2431- gen_sto_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg]));
2432+ gen_ldo_env_A0(s->mem_index, offsetof(CPUX86State,xmm_regs[reg]));
2433 break;
2434 case 0x22b: /* movntss */
2435 case 0x32b: /* movntsd */
2436@@ -4591,9 +4596,7 @@
2437 /* operand size for jumps is 64 bit */
2438 ot = OT_QUAD;
2439 } else if (op == 3 || op == 5) {
2440- /* for call calls, the operand is 16 or 32 bit, even
2441- in long mode */
2442- ot = dflag ? OT_LONG : OT_WORD;
2443+ ot = dflag ? OT_LONG + (rex_w == 1) : OT_WORD;
2444 } else if (op == 6) {
2445 /* default push size is 64 bit */
2446 ot = dflag ? OT_QUAD : OT_WORD;
2447
2448=== modified file 'target-sh4/cpu.h'
2449--- target-sh4/cpu.h 2010-01-20 17:54:24 +0000
2450+++ target-sh4/cpu.h 2010-06-11 20:46:30 +0000
2451@@ -167,6 +167,7 @@
2452 void do_interrupt(CPUSH4State * env);
2453
2454 void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
2455+void cpu_sh4_invalidate_tlb(CPUSH4State *s);
2456 void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
2457 uint32_t mem_value);
2458
2459@@ -222,6 +223,7 @@
2460 /* MMU control register */
2461 #define MMUCR 0x1F000010
2462 #define MMUCR_AT (1<<0)
2463+#define MMUCR_TI (1<<2)
2464 #define MMUCR_SV (1<<8)
2465 #define MMUCR_URC_BITS (6)
2466 #define MMUCR_URC_OFFSET (10)
2467
2468=== modified file 'target-sh4/helper.c'
2469--- target-sh4/helper.c 2009-08-04 12:36:50 +0000
2470+++ target-sh4/helper.c 2010-06-11 20:46:30 +0000
2471@@ -377,7 +377,7 @@
2472 n = find_itlb_entry(env, address, use_asid, 1);
2473 if (n >= 0) {
2474 matching = &env->itlb[n];
2475- if ((env->sr & SR_MD) & !(matching->pr & 2))
2476+ if (!(env->sr & SR_MD) && !(matching->pr & 2))
2477 n = MMU_ITLB_VIOLATION;
2478 else
2479 *prot = PAGE_READ;
2480@@ -430,7 +430,7 @@
2481 if ((address >= 0x80000000 && address < 0xc0000000) ||
2482 address >= 0xe0000000) {
2483 if (!(env->sr & SR_MD)
2484- && (address < 0xe0000000 || address > 0xe4000000)) {
2485+ && (address < 0xe0000000 || address >= 0xe4000000)) {
2486 /* Unauthorized access in user mode (only store queues are available) */
2487 fprintf(stderr, "Unauthorized access\n");
2488 if (rw == 0)
2489@@ -574,6 +574,24 @@
2490 entry->tc = (uint8_t)cpu_ptea_tc(env->ptea);
2491 }
2492
2493+ void cpu_sh4_invalidate_tlb(CPUSH4State *s)
2494+{
2495+ int i;
2496+
2497+ /* UTLB */
2498+ for (i = 0; i < UTLB_SIZE; i++) {
2499+ tlb_t * entry = &s->utlb[i];
2500+ entry->v = 0;
2501+ }
2502+ /* ITLB */
2503+ for (i = 0; i < UTLB_SIZE; i++) {
2504+ tlb_t * entry = &s->utlb[i];
2505+ entry->v = 0;
2506+ }
2507+
2508+ tlb_flush(s, 1);
2509+}
2510+
2511 void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
2512 uint32_t mem_value)
2513 {
2514
2515=== modified file 'target-sh4/translate.c'
2516--- target-sh4/translate.c 2010-01-20 17:54:24 +0000
2517+++ target-sh4/translate.c 2010-06-11 20:46:30 +0000
2518@@ -1905,7 +1905,7 @@
2519 ctx.bstate = BS_NONE;
2520 ctx.sr = env->sr;
2521 ctx.fpscr = env->fpscr;
2522- ctx.memidx = (env->sr & SR_MD) ? 1 : 0;
2523+ ctx.memidx = (env->sr & SR_MD) == 0 ? 1 : 0;
2524 /* We don't know if the delayed pc came from a dynamic or static branch,
2525 so assume it is a dynamic branch. */
2526 ctx.delayed_pc = -1; /* use delayed pc from env pointer */
2527
2528=== modified file 'tcg/arm/tcg-target.c'
2529--- tcg/arm/tcg-target.c 2010-01-20 17:54:24 +0000
2530+++ tcg/arm/tcg-target.c 2010-06-11 20:46:30 +0000
2531@@ -1697,12 +1697,15 @@
2532
2533 void tcg_target_qemu_prologue(TCGContext *s)
2534 {
2535- /* stmdb sp!, { r9 - r11, lr } */
2536- tcg_out32(s, (COND_AL << 28) | 0x092d4e00);
2537+ /* Theoretically there is no need to save r12, but an
2538+ even number of registers to be saved as per EABI */
2539+
2540+ /* stmdb sp!, { r4 - r12, lr } */
2541+ tcg_out32(s, (COND_AL << 28) | 0x092d5ff0);
2542
2543 tcg_out_bx(s, COND_AL, TCG_REG_R0);
2544 tb_ret_addr = s->code_ptr;
2545
2546- /* ldmia sp!, { r9 - r11, pc } */
2547- tcg_out32(s, (COND_AL << 28) | 0x08bd8e00);
2548+ /* ldmia sp!, { r4 - r12, pc } */
2549+ tcg_out32(s, (COND_AL << 28) | 0x08bd9ff0);
2550 }
2551
2552=== modified file 'tcg/mips/tcg-target.c'
2553--- tcg/mips/tcg-target.c 2010-02-26 16:26:00 +0000
2554+++ tcg/mips/tcg-target.c 2010-06-11 20:46:30 +0000
2555@@ -340,6 +340,17 @@
2556 }
2557
2558 /*
2559+ * Type branch
2560+ */
2561+static inline void tcg_out_opc_br(TCGContext *s, int opc, int rt, int rs)
2562+{
2563+ /* We need to keep the offset unchanged for retranslation */
2564+ uint16_t offset = (uint16_t)(*(uint32_t *) &s->code_ptr);
2565+
2566+ tcg_out_opc_imm(s, opc, rt, rs, offset);
2567+}
2568+
2569+/*
2570 * Type sa
2571 */
2572 static inline void tcg_out_opc_sa(TCGContext *s, int opc, int rd, int rt, int sa)
2573@@ -469,42 +480,42 @@
2574
2575 switch (cond) {
2576 case TCG_COND_EQ:
2577- tcg_out_opc_imm(s, OPC_BEQ, arg1, arg2, 0);
2578+ tcg_out_opc_br(s, OPC_BEQ, arg1, arg2);
2579 break;
2580 case TCG_COND_NE:
2581- tcg_out_opc_imm(s, OPC_BNE, arg1, arg2, 0);
2582+ tcg_out_opc_br(s, OPC_BNE, arg1, arg2);
2583 break;
2584 case TCG_COND_LT:
2585 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg1, arg2);
2586- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
2587+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO);
2588 break;
2589 case TCG_COND_LTU:
2590 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg1, arg2);
2591- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
2592+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO);
2593 break;
2594 case TCG_COND_GE:
2595 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg1, arg2);
2596- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
2597+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO);
2598 break;
2599 case TCG_COND_GEU:
2600 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg1, arg2);
2601- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
2602+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO);
2603 break;
2604 case TCG_COND_LE:
2605 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg2, arg1);
2606- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
2607+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO);
2608 break;
2609 case TCG_COND_LEU:
2610 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg2, arg1);
2611- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO, 0);
2612+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_AT, TCG_REG_ZERO);
2613 break;
2614 case TCG_COND_GT:
2615 tcg_out_opc_reg(s, OPC_SLT, TCG_REG_AT, arg2, arg1);
2616- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
2617+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO);
2618 break;
2619 case TCG_COND_GTU:
2620 tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_AT, arg2, arg1);
2621- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO, 0);
2622+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_AT, TCG_REG_ZERO);
2623 break;
2624 default:
2625 tcg_abort();
2626@@ -553,7 +564,7 @@
2627 }
2628
2629 label_ptr = s->code_ptr;
2630- tcg_out_opc_imm(s, OPC_BNE, arg2, arg4, 0);
2631+ tcg_out_opc_br(s, OPC_BNE, arg2, arg4);
2632 tcg_out_nop(s);
2633
2634 switch(cond) {
2635@@ -670,20 +681,20 @@
2636
2637 # if TARGET_LONG_BITS == 64
2638 label3_ptr = s->code_ptr;
2639- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT, 0);
2640+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT);
2641 tcg_out_nop(s);
2642
2643 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
2644 offsetof(CPUState, tlb_table[mem_index][0].addr_read) + addr_memh);
2645
2646 label1_ptr = s->code_ptr;
2647- tcg_out_opc_imm(s, OPC_BEQ, addr_regh, TCG_REG_AT, 0);
2648+ tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
2649 tcg_out_nop(s);
2650
2651 reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
2652 # else
2653 label1_ptr = s->code_ptr;
2654- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT, 0);
2655+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);
2656 tcg_out_nop(s);
2657 # endif
2658
2659@@ -725,7 +736,7 @@
2660 }
2661
2662 label2_ptr = s->code_ptr;
2663- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO, 0);
2664+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);
2665 tcg_out_nop(s);
2666
2667 /* label1: fast path */
2668@@ -857,20 +868,20 @@
2669
2670 # if TARGET_LONG_BITS == 64
2671 label3_ptr = s->code_ptr;
2672- tcg_out_opc_imm(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT, 0);
2673+ tcg_out_opc_br(s, OPC_BNE, TCG_REG_T0, TCG_REG_AT);
2674 tcg_out_nop(s);
2675
2676 tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
2677 offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh);
2678
2679 label1_ptr = s->code_ptr;
2680- tcg_out_opc_imm(s, OPC_BEQ, addr_regh, TCG_REG_AT, 0);
2681+ tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
2682 tcg_out_nop(s);
2683
2684 reloc_pc16(label3_ptr, (tcg_target_long) s->code_ptr);
2685 # else
2686 label1_ptr = s->code_ptr;
2687- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT, 0);
2688+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_T0, TCG_REG_AT);
2689 tcg_out_nop(s);
2690 # endif
2691
2692@@ -911,7 +922,7 @@
2693 tcg_out_nop(s);
2694
2695 label2_ptr = s->code_ptr;
2696- tcg_out_opc_imm(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO, 0);
2697+ tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO);
2698 tcg_out_nop(s);
2699
2700 /* label1: fast path */
2701@@ -1262,7 +1273,9 @@
2702 };
2703
2704 static int tcg_target_callee_save_regs[] = {
2705+#if 0 /* used for the global env (TCG_AREG0), so no need to save */
2706 TCG_REG_S0,
2707+#endif
2708 TCG_REG_S1,
2709 TCG_REG_S2,
2710 TCG_REG_S3,
2711@@ -1271,8 +1284,7 @@
2712 TCG_REG_S6,
2713 TCG_REG_S7,
2714 TCG_REG_GP,
2715- /* TCG_REG_FP, */ /* currently used for the global env, so np
2716- need to save */
2717+ TCG_REG_FP,
2718 TCG_REG_RA, /* should be last for ABI compliance */
2719 };
2720
2721
2722=== modified file 'tcg/mips/tcg-target.h'
2723--- tcg/mips/tcg-target.h 2010-01-20 17:54:24 +0000
2724+++ tcg/mips/tcg-target.h 2010-06-11 20:46:30 +0000
2725@@ -92,9 +92,9 @@
2726 #undef TCG_TARGET_HAS_ext16u_i32 /* andi rt, rs, 0xffff */
2727
2728 /* Note: must be synced with dyngen-exec.h */
2729-#define TCG_AREG0 TCG_REG_FP
2730-#define TCG_AREG1 TCG_REG_S0
2731-#define TCG_AREG2 TCG_REG_S1
2732+#define TCG_AREG0 TCG_REG_S0
2733+#define TCG_AREG1 TCG_REG_S1
2734+#define TCG_AREG2 TCG_REG_FP
2735
2736 #include <sys/cachectl.h>
2737
2738
2739=== modified file 'vl.c'
2740--- vl.c 2010-02-26 16:26:00 +0000
2741+++ vl.c 2010-06-11 20:46:30 +0000
2742@@ -2597,9 +2597,9 @@
2743 fprintf(stderr,
2744 "only 63 CPUs in NUMA mode supported.\n");
2745 }
2746- value = (1 << (endvalue + 1)) - (1 << value);
2747+ value = (2ULL << endvalue) - (1ULL << value);
2748 } else {
2749- value = 1 << value;
2750+ value = 1ULL << value;
2751 }
2752 }
2753 node_cpumask[nodenr] = value;
2754@@ -3515,6 +3515,8 @@
2755 return 0;
2756 if (env->stopped)
2757 return 0;
2758+ if (!vm_running)
2759+ return 0;
2760 return 1;
2761 }
2762
2763@@ -4909,7 +4911,7 @@
2764 const char *gdbstub_dev = NULL;
2765 uint32_t boot_devices_bitmap = 0;
2766 int i;
2767- int snapshot, linux_boot, net_boot;
2768+ int snapshot, linux_boot;
2769 const char *initrd_filename;
2770 const char *kernel_filename, *kernel_cmdline;
2771 char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
2772@@ -5428,6 +5430,9 @@
2773 case QEMU_OPTION_serial:
2774 add_device_config(DEV_SERIAL, optarg);
2775 default_serial = 0;
2776+ if (strncmp(optarg, "mon:", 4) == 0) {
2777+ default_monitor = 0;
2778+ }
2779 break;
2780 case QEMU_OPTION_watchdog:
2781 if (watchdog) {
2782@@ -5446,10 +5451,16 @@
2783 case QEMU_OPTION_virtiocon:
2784 add_device_config(DEV_VIRTCON, optarg);
2785 default_virtcon = 0;
2786+ if (strncmp(optarg, "mon:", 4) == 0) {
2787+ default_monitor = 0;
2788+ }
2789 break;
2790 case QEMU_OPTION_parallel:
2791 add_device_config(DEV_PARALLEL, optarg);
2792 default_parallel = 0;
2793+ if (strncmp(optarg, "mon:", 4) == 0) {
2794+ default_monitor = 0;
2795+ }
2796 break;
2797 case QEMU_OPTION_loadvm:
2798 loadvm = optarg;
2799@@ -5905,6 +5916,12 @@
2800 fprintf(stderr, "Could not initialize KVM, will disable KVM support\n");
2801 kvm_allowed = 0;
2802 }
2803+ } else {
2804+ /* without kvm enabled, we can only support 4095 MB RAM */
2805+ if (ram_size > (4095UL << 20)) {
2806+ fprintf(stderr, "qemu: without kvm support at most 4095 MB RAM can be simulated\n");
2807+ exit(1);
2808+ }
2809 }
2810
2811 if (qemu_init_main_loop()) {
2812@@ -5948,9 +5965,6 @@
2813 exit(1);
2814 }
2815
2816- net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF;
2817- net_set_boot_mask(net_boot);
2818-
2819 /* init the bluetooth world */
2820 if (foreach_device_config(DEV_BT, bt_parse))
2821 exit(1);
2822
2823=== modified file 'vnc.c'
2824--- vnc.c 2010-02-26 16:26:00 +0000
2825+++ vnc.c 2010-06-11 20:46:30 +0000
2826@@ -1421,8 +1421,10 @@
2827 dz = 1;
2828
2829 if (vs->absolute) {
2830- kbd_mouse_event(x * 0x7FFF / (ds_get_width(vs->ds) - 1),
2831- y * 0x7FFF / (ds_get_height(vs->ds) - 1),
2832+ kbd_mouse_event(ds_get_width(vs->ds) > 1 ?
2833+ x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000,
2834+ ds_get_height(vs->ds) > 1 ?
2835+ y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000,
2836 dz, buttons);
2837 } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) {
2838 x -= 0x7FFF;

Subscribers

People subscribed via source and target branches