From: "Jan Beulich" Subject: [PATCH] 64-bit hvm on 32-bit dom0 - ioemu adjustments Date: Mon, 14 May 2007 17:07:09 +0200 Message-ID: <4648973D.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Don't mask off data bits when running 64-bit hvm guests on 32-bit dom0. Signed-off-by: Jan Beulich Index: 2007-04-27/tools/ioemu/target-i386-dm/helper2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-04-27.orig/tools/ioemu/target-i386-dm/helper2.c 2007-04-23 = 12:41:32.000000000 +0200 +++ 2007-04-27/tools/ioemu/target-i386-dm/helper2.c 2007-05-09 = 17:58:07.000000000 +0200 @@ -322,7 +322,7 @@ void cpu_ioreq_pio(CPUState *env, ioreq_ do_outp(env, req->addr, req->size, req->data); } else { for (i =3D 0; i < req->count; i++) { - unsigned long tmp; + unsigned long tmp =3D 0; =20 read_physical((target_phys_addr_t) req->data + (sign * i * req->size), @@ -354,7 +354,7 @@ void cpu_ioreq_move(CPUState *env, ioreq } } } else { - unsigned long tmp; + target_ulong tmp; =20 if (req->dir =3D=3D IOREQ_READ) { for (i =3D 0; i < req->count; i++) { @@ -380,14 +380,14 @@ void cpu_ioreq_move(CPUState *env, ioreq =20 void cpu_ioreq_and(CPUState *env, ioreq_t *req) { - unsigned long tmp1, tmp2; + target_ulong tmp1, tmp2; =20 if (req->data_is_ptr !=3D 0) hw_error("expected scalar value"); =20 read_physical(req->addr, req->size, &tmp1); if (req->dir =3D=3D IOREQ_WRITE) { - tmp2 =3D tmp1 & (unsigned long) req->data; + tmp2 =3D tmp1 & (target_ulong) req->data; write_physical(req->addr, req->size, &tmp2); } req->data =3D tmp1; @@ -395,14 +395,14 @@ void cpu_ioreq_and(CPUState *env, ioreq_ =20 void cpu_ioreq_add(CPUState *env, ioreq_t *req) { - unsigned long tmp1, tmp2; + target_ulong tmp1, tmp2; =20 if (req->data_is_ptr !=3D 0) hw_error("expected scalar value"); =20 read_physical(req->addr, req->size, &tmp1); if (req->dir =3D=3D IOREQ_WRITE) { - tmp2 =3D tmp1 + (unsigned long) req->data; + tmp2 =3D tmp1 + (target_ulong) req->data; write_physical(req->addr, req->size, &tmp2); } req->data =3D tmp1; @@ -410,14 +410,14 @@ void cpu_ioreq_add(CPUState *env, ioreq_ =20 void cpu_ioreq_sub(CPUState *env, ioreq_t *req) { - unsigned long tmp1, tmp2; + target_ulong tmp1, tmp2; =20 if (req->data_is_ptr !=3D 0) hw_error("expected scalar value"); =20 read_physical(req->addr, req->size, &tmp1); if (req->dir =3D=3D IOREQ_WRITE) { - tmp2 =3D tmp1 - (unsigned long) req->data; + tmp2 =3D tmp1 - (target_ulong) req->data; write_physical(req->addr, req->size, &tmp2); } req->data =3D tmp1; @@ -425,14 +425,14 @@ void cpu_ioreq_sub(CPUState *env, ioreq_ =20 void cpu_ioreq_or(CPUState *env, ioreq_t *req) { - unsigned long tmp1, tmp2; + target_ulong tmp1, tmp2; =20 if (req->data_is_ptr !=3D 0) hw_error("expected scalar value"); =20 read_physical(req->addr, req->size, &tmp1); if (req->dir =3D=3D IOREQ_WRITE) { - tmp2 =3D tmp1 | (unsigned long) req->data; + tmp2 =3D tmp1 | (target_ulong) req->data; write_physical(req->addr, req->size, &tmp2); } req->data =3D tmp1; @@ -440,14 +440,14 @@ void cpu_ioreq_or(CPUState *env, ioreq_t =20 void cpu_ioreq_xor(CPUState *env, ioreq_t *req) { - unsigned long tmp1, tmp2; + target_ulong tmp1, tmp2; =20 if (req->data_is_ptr !=3D 0) hw_error("expected scalar value"); =20 read_physical(req->addr, req->size, &tmp1); if (req->dir =3D=3D IOREQ_WRITE) { - tmp2 =3D tmp1 ^ (unsigned long) req->data; + tmp2 =3D tmp1 ^ (target_ulong) req->data; write_physical(req->addr, req->size, &tmp2); } req->data =3D tmp1; @@ -495,8 +495,9 @@ void cpu_ioreq_xchg(CPUState *env, ioreq =20 void __handle_ioreq(CPUState *env, ioreq_t *req) { - if (!req->data_is_ptr && req->dir =3D=3D IOREQ_WRITE && req->size = !=3D 4) - req->data &=3D (1UL << (8 * req->size)) - 1; + if (!req->data_is_ptr && req->dir =3D=3D IOREQ_WRITE && + req->size < sizeof(target_ulong)) + req->data &=3D ((target_ulong)1 << (8 * req->size)) - 1; =20 switch (req->type) { case IOREQ_TYPE_PIO: