Skip to contentSkip to conversation

linux-user fixes for 1.2

GIT PULL New [email protected] 1 participant 4 messages Aug 27, 2012

lore
Share & tools
lore
#0 lore raw

From: Riku Voipio <[email protected]>

Hi,

The following changes since commit d03c98d80ffb7c561d9e6874580f52fe7ecc8c6c:

tcg/ia64: fix and optimize ld/st slow path (2012-08-26 21:10:37 +0200)

are available in the git repository at:

git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream

for you to fetch changes up to 097b8cb840a31ec526cc58778bd8cbab0d2beaaa:

linux-user: Clarify "Unable to reserve guest address space" error (2012-08-27 10:18:01 +0300)

Dmitry V. Levin (1):
linux-user: fix emulation of getdents

Jim Meyering (1):
linux-user: arg_table need not have global scope

Peter Maydell (1):
linux-user: Clarify "Unable to reserve guest address space" error

 linux-user/main.c         |   11 +++++++----
 linux-user/syscall.c      |   11 +++++------
 linux-user/syscall_defs.h |    8 ++++----
 3 files changed, 16 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 linux-user: arg_table need not have global scope

From: Jim Meyering <[email protected]>

Declare arg_table to be "static const", and adjust the two users to also be const.

---
 linux-user/main.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/main.c +3 -3
index 7dea084..b1c228a 100644
@@ -3222,7 +3222,7 @@ struct qemu_argument {
     const char *help;
 };
 
-struct qemu_argument arg_table[] = {
+static const struct qemu_argument arg_table[] = {
     {"h",          "",                 false, handle_arg_help,
      "",           "print this help"},
     {"g",          "QEMU_GDB",         true,  handle_arg_gdb,
@@ -3264,7 +3264,7 @@ struct qemu_argument arg_table[] = {
 
 static void usage(void)
 {
-    struct qemu_argument *arginfo;
+    const struct qemu_argument *arginfo;
     int maxarglen;
     int maxenvlen;
 
@@ -3330,7 +3330,7 @@ static int parse_args(int argc, char **argv)
 {
     const char *r;
     int optind;
-    struct qemu_argument *arginfo;
+    const struct qemu_argument *arginfo;
 
     for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
         if (arginfo->env == NULL) {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 linux-user: fix emulation of getdents

In reply to [email protected]

From: "Dmitry V. Levin" <[email protected]>

In case when TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64, the last byte of the target dirent structure (aka d_type byte) was never copied from the host dirent structure, thus breaking everything that relies on valid d_type value, e.g. glob(3).

---
 linux-user/syscall.c      |   11 +++++------
 linux-user/syscall_defs.h |    8 ++++----
 2 files changed, 9 insertions(+), 10 deletions(-)
linux-user/syscall.c +5 -6
index 1174306..6257a04 100644
@@ -7025,15 +7025,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 		tde = target_dirp;
                 while (len > 0) {
                     reclen = de->d_reclen;
-		    treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
+                    tnamelen = reclen - offsetof(struct linux_dirent, d_name);
+                    assert(tnamelen >= 0);
+                    treclen = tnamelen + offsetof(struct target_dirent, d_name);
+                    assert(count1 + treclen <= count);
                     tde->d_reclen = tswap16(treclen);
                     tde->d_ino = tswapal(de->d_ino);
                     tde->d_off = tswapal(de->d_off);
-		    tnamelen = treclen - (2 * sizeof(abi_long) + 2);
-		    if (tnamelen > 256)
-                        tnamelen = 256;
-                    /* XXX: may not be correct */
-                    pstrcpy(tde->d_name, tnamelen, de->d_name);
+                    memcpy(tde->d_name, de->d_name, tnamelen);
                     de = (struct linux_dirent *)((char *)de + reclen);
                     len -= reclen;
                     tde = (struct target_dirent *)((char *)tde + treclen);
linux-user/syscall_defs.h +4 -4
index 2cfda5a..a98cbf7 100644
@@ -255,10 +255,10 @@ struct kernel_statfs {
 };
 
 struct target_dirent {
-	abi_long	d_ino;
-	abi_long	d_off;
-	unsigned short	d_reclen;
-	char		d_name[256]; /* We must not include limits.h! */
+        abi_long        d_ino;
+        abi_long        d_off;
+        unsigned short  d_reclen;
+        char            d_name[];
 };
 
 struct target_dirent64 {
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 linux-user: Clarify "Unable to reserve guest address space" error

In reply to [email protected]

From: Peter Maydell <[email protected]>

Now that we default to reserving nearly 4GB of RAM for the guest address space when running a 32 bit linux-user guest on 64 bit hosts, users are much more likely to run into it. Reword the message to be more informative about what failed and provide suggestions for how to fix things.

---
 linux-user/main.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
linux-user/main.c +4 -1
index b1c228a..1a1c661 100644
@@ -3519,7 +3519,10 @@ int main(int argc, char **argv, char **envp)
         guest_base = init_guest_space(guest_base, reserved_va, 0,
                                       have_guest_base);
         if (guest_base == (unsigned long)-1) {
-            fprintf(stderr, "Unable to reserve guest address space\n");
+            fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual address "
+                    "space for use as guest address space (check your virtual "
+                    "memory ulimit setting or reserve less using -R option)\n",
+                    reserved_va);
             exit(1);
         }
 
Signature · 1 line
1.7.9.5