From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297341; cv=none; d=zoho.com; s=zohoarc; b=mHXchSTyrVYuBw6oOdzLGFhf3SO31/SfOuBVlldZaqHsPO5xFwhvwKP6g7qF6bQ9wfYBeNY/LOQQqemMuNjrUxpdt4Wp1IAqCArHzUAsNg3z7aPdpYHvtwmyfMwfsP3/iWcdPkpkCv06R2+uxYx2hpzAQ+qs78VobxDgasxAVBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297341; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=F6v6DXx3p/jSQwESHeV1J+7APHSrqQWGEt14uQc8gHo=; b=VTTH65xtsXQ/0SNNwTC3eQtSGNcmRS/JEbOioz/+CtDy7bobl+gyxuXbKgiV1l1JcBCjLEjV3XC4UZSTK6STLJMUvBmyUevWvkWQy4GSGvjALRXTezUUnVVxPh1NoM630n+NSwa9rc4ViHIBlpVfh4YX9iYnBKFNQufKZrBkgyY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297341693284.45581551679913; Sun, 19 May 2019 13:22:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:52866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSJr-0006vK-Q1 for importer@patchew.org; Sun, 19 May 2019 16:22:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHo-0005PI-Ft for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHn-0007I9-6z for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:00 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:43788) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHn-0007HV-0m for qemu-devel@nongnu.org; Sun, 19 May 2019 16:19:59 -0400 Received: by mail-pf1-x443.google.com with SMTP id c6so6140816pfa.10 for ; Sun, 19 May 2019 13:19:58 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.19.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F6v6DXx3p/jSQwESHeV1J+7APHSrqQWGEt14uQc8gHo=; b=LNoyoleiOmWy0+b5gqhq8DClyyS7FdElq0Iyolo/4h3pAWSQOECoXCfuj6RQ8Fd3yo RqZOpo3P9VyQKhkETAtVf/1MhSofklJRjqtm4ZdmyqVu86sf7VStdm+C1ldRqT7bFZZf McXkW0M/tQ8SHgNu487ySJUA1x40uJZRmYoCZHAO5u+B8cUFLUiHaIz+RA6uBNOmZed7 8TkwyIeZhaJNE/+/EzYjLru742oJAL43oEl3nv1zVvWaCgxhrLygcsqLi8/v6BJY5t0r z71BEx/7b1Pw08/dtu/WPt4pYR4Itu720vbE1moZINx9+7XAUQ74OpZfYyRhUF3aRTVM MXQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F6v6DXx3p/jSQwESHeV1J+7APHSrqQWGEt14uQc8gHo=; b=TXcytjB5kN1GHt5qUgwLMjo/8R7WKp7YoH2FDD7bnguMA8o76Y25uNrQ5Ek7QcdIQr cH0ok141Vz32ajLq7/ImV+yKQSkaqwC/tKnwxj8QQpJauSxyF5nbhfw71/jm6hKUS77M xyeu/rWmwBJ4XsA3YzyahcHpaUHNXVCDBkUsp0bBOsSzmkS9B+ISpgnshlBQZmECFLf2 wYe/AOOzm0/4gGVvhlnQ5Lt8pB87NzgGPxeW0LtYOWLfEteLJMeK0N2WXqze7EBopW8p w6V/XOMVDdFryF624e2JwhstkUFEVHu54jQQSNcx/8qETQjMCtPqVlx3qm58M4rX20gZ 0Jhg== X-Gm-Message-State: APjAAAVJqzL5DnY3xO/hneECmiLMin24s9lHKQ1H3ewQfGCuaekYPL4w dXyRao1T5WO7Lj/LoyAsm/MTVOuCuiM= X-Google-Smtp-Source: APXvYqx+Yhbor1WoBqlmIXCyQyXQzlpLrRCxiHTAQert1WXxy18ZDXEN/WFM/tgzFZhhYFfv8eUurA== X-Received: by 2002:a63:144e:: with SMTP id 14mr53861332pgu.304.1558297197610; Sun, 19 May 2019 13:19:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:41 -0700 Message-Id: <20190519201953.20161-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH 01/13] util/path: Do not cache all filenames at startup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If one uses -L $PATH to point to a full chroot, the startup time is significant. In addition, the existing probing algorithm fails to handle symlink loops. Instead, probe individual paths on demand. Cache both positive and negative results within $PATH, so that any one filename is probed only once. Use glib filename functions for clarity. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Tested-by: Laurent Vivier --- util/path.c | 201 ++++++++++++---------------------------------------- 1 file changed, 47 insertions(+), 154 deletions(-) diff --git a/util/path.c b/util/path.c index 7f9fc272fb..8e174eb436 100644 --- a/util/path.c +++ b/util/path.c @@ -8,170 +8,63 @@ #include #include "qemu/cutils.h" #include "qemu/path.h" +#include "qemu/thread.h" =20 -struct pathelem -{ - /* Name of this, eg. lib */ - char *name; - /* Full path name, eg. /usr/gnemul/x86-linux/lib. */ - char *pathname; - struct pathelem *parent; - /* Children */ - unsigned int num_entries; - struct pathelem *entries[0]; -}; - -static struct pathelem *base; - -/* First N chars of S1 match S2, and S2 is N chars long. */ -static int strneq(const char *s1, unsigned int n, const char *s2) -{ - unsigned int i; - - for (i =3D 0; i < n; i++) - if (s1[i] !=3D s2[i]) - return 0; - return s2[i] =3D=3D 0; -} - -static struct pathelem *add_entry(struct pathelem *root, const char *name, - unsigned type); - -static struct pathelem *new_entry(const char *root, - struct pathelem *parent, - const char *name) -{ - struct pathelem *new =3D g_malloc(sizeof(*new)); - new->name =3D g_strdup(name); - new->pathname =3D g_strdup_printf("%s/%s", root, name); - new->num_entries =3D 0; - return new; -} - -#define streq(a,b) (strcmp((a), (b)) =3D=3D 0) - -/* Not all systems provide this feature */ -#if defined(DT_DIR) && defined(DT_UNKNOWN) && defined(DT_LNK) -# define dirent_type(dirent) ((dirent)->d_type) -# define is_dir_maybe(type) \ - ((type) =3D=3D DT_DIR || (type) =3D=3D DT_UNKNOWN || (type) =3D=3D DT_= LNK) -#else -# define dirent_type(dirent) (1) -# define is_dir_maybe(type) (type) -#endif - -static struct pathelem *add_dir_maybe(struct pathelem *path) -{ - DIR *dir; - - if ((dir =3D opendir(path->pathname)) !=3D NULL) { - struct dirent *dirent; - - while ((dirent =3D readdir(dir)) !=3D NULL) { - if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){ - path =3D add_entry(path, dirent->d_name, dirent_type(diren= t)); - } - } - closedir(dir); - } - return path; -} - -static struct pathelem *add_entry(struct pathelem *root, const char *name, - unsigned type) -{ - struct pathelem **e; - - root->num_entries++; - - root =3D g_realloc(root, sizeof(*root) - + sizeof(root->entries[0])*root->num_entries); - e =3D &root->entries[root->num_entries-1]; - - *e =3D new_entry(root->pathname, root, name); - if (is_dir_maybe(type)) { - *e =3D add_dir_maybe(*e); - } - - return root; -} - -/* This needs to be done after tree is stabilized (ie. no more reallocs!).= */ -static void set_parents(struct pathelem *child, struct pathelem *parent) -{ - unsigned int i; - - child->parent =3D parent; - for (i =3D 0; i < child->num_entries; i++) - set_parents(child->entries[i], child); -} - -/* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */ -static const char * -follow_path(const struct pathelem *cursor, const char *name) -{ - unsigned int i, namelen; - - name +=3D strspn(name, "/"); - namelen =3D strcspn(name, "/"); - - if (namelen =3D=3D 0) - return cursor->pathname; - - if (strneq(name, namelen, "..")) - return follow_path(cursor->parent, name + namelen); - - if (strneq(name, namelen, ".")) - return follow_path(cursor, name + namelen); - - for (i =3D 0; i < cursor->num_entries; i++) - if (strneq(name, namelen, cursor->entries[i]->name)) - return follow_path(cursor->entries[i], name + namelen); - - /* Not found */ - return NULL; -} +static const char *base; +static GHashTable *hash; +static QemuMutex lock; =20 void init_paths(const char *prefix) { - char pref_buf[PATH_MAX]; - - if (prefix[0] =3D=3D '\0' || - !strcmp(prefix, "/")) + if (prefix[0] =3D=3D '\0' || !strcmp(prefix, "/")) { return; - - if (prefix[0] !=3D '/') { - char *cwd =3D getcwd(NULL, 0); - size_t pref_buf_len =3D sizeof(pref_buf); - - if (!cwd) - abort(); - pstrcpy(pref_buf, sizeof(pref_buf), cwd); - pstrcat(pref_buf, pref_buf_len, "/"); - pstrcat(pref_buf, pref_buf_len, prefix); - free(cwd); - } else - pstrcpy(pref_buf, sizeof(pref_buf), prefix + 1); - - base =3D new_entry("", NULL, pref_buf); - base =3D add_dir_maybe(base); - if (base->num_entries =3D=3D 0) { - g_free(base->pathname); - g_free(base->name); - g_free(base); - base =3D NULL; - } else { - set_parents(base, base); } + + if (prefix[0] =3D=3D '/') { + base =3D g_strdup(prefix); + } else { + char *cwd =3D g_get_current_dir(); + base =3D g_build_filename(cwd, prefix, NULL); + g_free(cwd); + } + + hash =3D g_hash_table_new(g_str_hash, g_str_equal); + qemu_mutex_init(&lock); } =20 /* Look for path in emulation dir, otherwise return name. */ const char *path(const char *name) { - /* Only do absolute paths: quick and dirty, but should mostly be OK. - Could do relative by tracking cwd. */ - if (!base || !name || name[0] !=3D '/') - return name; + gpointer key, value; + const char *ret; =20 - return follow_path(base, name) ?: name; + /* Only do absolute paths: quick and dirty, but should mostly be OK. = */ + if (!base || !name || name[0] !=3D '/') { + return name; + } + + qemu_mutex_lock(&lock); + + /* Have we looked up this file before? */ + if (g_hash_table_lookup_extended(hash, name, &key, &value)) { + ret =3D value ? value : name; + } else { + char *save =3D g_strdup(name); + char *full =3D g_build_filename(base, name, NULL); + + /* Look for the path; record the result, pass or fail. */ + if (access(full, F_OK) =3D=3D 0) { + /* Exists. */ + g_hash_table_insert(hash, save, full); + ret =3D full; + } else { + /* Does not exist. */ + g_free(full); + g_hash_table_insert(hash, save, NULL); + ret =3D name; + } + } + + qemu_mutex_unlock(&lock); + return ret; } --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297503; cv=none; d=zoho.com; s=zohoarc; b=LijzfbVkEjyMK2eTvHdi8VpjoO4EC5GGJtlsIEW1fWpClxlzhowW+NLONqWVcC/jluD3U/lDlKiul1GotjUcgEijSj5aiXPJnbACaj/w1ZZCUHD5B/tUhJfac7C3LRD+23D8OvwoGJUjv988hmGNmFiVE+ycwQvL3I+kvwJgvx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297503; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rXfSo9Gy+xV7gUMCOu/4nLM098jgkgLPcgtIQzZJ9xs=; b=NkubuarneR+JwiH97HgUdePT9EYI1Pkqdbq3oc8pzSWbVP3uofOsTlzd3qas3yQnFJuZQIlXZjvaV2lHceuhg4NI9ZcCPy0CPQC+dNCWWcf0GTt8ccRlGW9R2QSgfa4MmpgQe9Hzmon+U9caHNMfv8sA3o94OqDhlNjf1mzIuOQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297503609809.6131599549876; Sun, 19 May 2019 13:25:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:52897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSMf-0000va-VN for importer@patchew.org; Sun, 19 May 2019 16:25:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHq-0005PW-5h for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHo-0007Js-IK for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:02 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:43740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHo-0007Ih-Ah for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:00 -0400 Received: by mail-pg1-x544.google.com with SMTP id t22so5715991pgi.10 for ; Sun, 19 May 2019 13:20:00 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rXfSo9Gy+xV7gUMCOu/4nLM098jgkgLPcgtIQzZJ9xs=; b=JTjGItOnSMUIYHEEx5LZcLs7Twjd7TMSj3wNUZ+d60cBs4W8wptlXMzptMdWdOtF4n ZuoNaPGwTftRP4fsqpL9HToIITohaOSgoWS/xtKJXmGB6tq/Ank+ff+G+OB4bpZ28ebS ayaDIgVw/SM6EDqCX2Rs5dLA0cF+kVAnS6uSTgaQ6YNzbPya4DLUJFrtNrJqZ3/xw7xg 9fMDZDIXTdDeP2eLN3NdzvHgHS/VMWW3WRpJGThf+Ar3mO1LDGl6ZgSh0WzCed9tJd0V uXpBPIKwgc62LVdaC4AWght+LNHYtS69c4A9pbDvhLKuEIA+R0SVONZj2Jo/+eOvI1eb rxmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rXfSo9Gy+xV7gUMCOu/4nLM098jgkgLPcgtIQzZJ9xs=; b=H/N/7ZQniFA8ZlgR15JMWN02AZxaUoaFevFNyvdk/c6Xv7Zp2Fg5VM6wPp4H0dMLU+ eL1DwamIsJjAVlkfHbShG5d2alMjUTGqejAY4ZmLOK1jn2IOt5wJQGavHr+/ZGkDh6N9 f1SXJLKXLtpoi8gvho6cvyGB5l4ODjZFFmRS9aNL0pmpxrxnQ73Fr+A6GZ3PbyjyMpnD hjLLyb9Z3srMvm3FRnuKdrgcEpsdbMUI/2Pqi8Tba1iqguhg64f5MygGj6DZApOUKYRP HJJPy2u4BGdcww6l0e7Fobvk3pRYJH/416QISPYpSjS7gKYzrOoGCMlbuwtIVBOZlfiZ 69Aw== X-Gm-Message-State: APjAAAWk8gASfPMPYbnJstcKJDDrc8xbs0jEWJPBZUoRKaZtd20s/50z 40rUdIabpDigGlk9o3Ti9vTJKWnt/Dc= X-Google-Smtp-Source: APXvYqwTh9zthvi2YP2sgcRlrl12LpIWwGDP+nVwqZOIdUWsa3pQ30xvbksYCzmUnS6gH4vZiUyOPA== X-Received: by 2002:a65:60d2:: with SMTP id r18mr24719608pgv.217.1558297198793; Sun, 19 May 2019 13:19:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:42 -0700 Message-Id: <20190519201953.20161-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH 02/13] linux-user: Rename cpu_clone_regs to cpu_clone_regs_child X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We will need a target-specific hook for adjusting registers in the parent during clone. To avoid confusion, rename the one we have to make it clear it affects the child. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/aarch64/target_cpu.h | 2 +- linux-user/alpha/target_cpu.h | 2 +- linux-user/arm/target_cpu.h | 2 +- linux-user/cris/target_cpu.h | 2 +- linux-user/hppa/target_cpu.h | 2 +- linux-user/i386/target_cpu.h | 2 +- linux-user/m68k/target_cpu.h | 2 +- linux-user/microblaze/target_cpu.h | 2 +- linux-user/mips/target_cpu.h | 2 +- linux-user/nios2/target_cpu.h | 2 +- linux-user/openrisc/target_cpu.h | 3 ++- linux-user/ppc/target_cpu.h | 2 +- linux-user/riscv/target_cpu.h | 2 +- linux-user/s390x/target_cpu.h | 2 +- linux-user/sh4/target_cpu.h | 2 +- linux-user/sparc/target_cpu.h | 2 +- linux-user/tilegx/target_cpu.h | 2 +- linux-user/xtensa/target_cpu.h | 3 ++- linux-user/syscall.c | 4 ++-- 19 files changed, 22 insertions(+), 20 deletions(-) diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cp= u.h index a021c95fa4..abde35b104 100644 --- a/linux-user/aarch64/target_cpu.h +++ b/linux-user/aarch64/target_cpu.h @@ -19,7 +19,7 @@ #ifndef AARCH64_TARGET_CPU_H #define AARCH64_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong new= sp) { if (newsp) { env->xregs[31] =3D newsp; diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h index ac4d255ae7..dc02f2234c 100644 --- a/linux-user/alpha/target_cpu.h +++ b/linux-user/alpha/target_cpu.h @@ -19,7 +19,7 @@ #ifndef ALPHA_TARGET_CPU_H #define ALPHA_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUAlphaState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUAlphaState *env, target_ulong n= ewsp) { if (newsp) { env->ir[IR_SP] =3D newsp; diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index 8a3764919a..d35c997287 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -23,7 +23,7 @@ See validate_guest_space in linux-user/elfload.c. */ #define MAX_RESERVED_VA 0xffff0000ul =20 -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong new= sp) { if (newsp) { env->regs[13] =3D newsp; diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h index 2309343979..9c847caaef 100644 --- a/linux-user/cris/target_cpu.h +++ b/linux-user/cris/target_cpu.h @@ -20,7 +20,7 @@ #ifndef CRIS_TARGET_CPU_H #define CRIS_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUCRISState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUCRISState *env, target_ulong ne= wsp) { if (newsp) { env->regs[14] =3D newsp; diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h index 1c539bdbd6..b98e5a1cfe 100644 --- a/linux-user/hppa/target_cpu.h +++ b/linux-user/hppa/target_cpu.h @@ -19,7 +19,7 @@ #ifndef HPPA_TARGET_CPU_H #define HPPA_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUHPPAState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUHPPAState *env, target_ulong ne= wsp) { if (newsp) { env->gr[30] =3D newsp; diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h index ece04d0966..e1c9e03490 100644 --- a/linux-user/i386/target_cpu.h +++ b/linux-user/i386/target_cpu.h @@ -20,7 +20,7 @@ #ifndef I386_TARGET_CPU_H #define I386_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUX86State *env, target_ulong new= sp) { if (newsp) { env->regs[R_ESP] =3D newsp; diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index 7a26f3c3fc..7637a98cab 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -21,7 +21,7 @@ #ifndef M68K_TARGET_CPU_H #define M68K_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUM68KState *env, target_ulong ne= wsp) { if (newsp) { env->aregs[7] =3D newsp; diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/tar= get_cpu.h index 73e139938c..526b80d54d 100644 --- a/linux-user/microblaze/target_cpu.h +++ b/linux-user/microblaze/target_cpu.h @@ -19,7 +19,7 @@ #ifndef MICROBLAZE_TARGET_CPU_H #define MICROBLAZE_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUMBState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMBState *env, target_ulong news= p) { if (newsp) { env->regs[R_SP] =3D newsp; diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h index 02cf5eeff7..c42660b047 100644 --- a/linux-user/mips/target_cpu.h +++ b/linux-user/mips/target_cpu.h @@ -19,7 +19,7 @@ #ifndef MIPS_TARGET_CPU_H #define MIPS_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUMIPSState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMIPSState *env, target_ulong ne= wsp) { if (newsp) { env->active_tc.gpr[29] =3D newsp; diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h index 5596c05c9c..bec2ea79c4 100644 --- a/linux-user/nios2/target_cpu.h +++ b/linux-user/nios2/target_cpu.h @@ -20,7 +20,7 @@ #ifndef NIOS2_TARGET_CPU_H #define NIOS2_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUNios2State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUNios2State *env, target_ulong n= ewsp) { if (newsp) { env->regs[R_SP] =3D newsp; diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_= cpu.h index 32ff135089..d163ba2e26 100644 --- a/linux-user/openrisc/target_cpu.h +++ b/linux-user/openrisc/target_cpu.h @@ -20,7 +20,8 @@ #ifndef OPENRISC_TARGET_CPU_H #define OPENRISC_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong news= p) +static inline void cpu_clone_regs_child(CPUOpenRISCState *env, + target_ulong newsp) { if (newsp) { cpu_set_gpr(env, 1, newsp); diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h index c4641834e7..34decf3876 100644 --- a/linux-user/ppc/target_cpu.h +++ b/linux-user/ppc/target_cpu.h @@ -19,7 +19,7 @@ #ifndef PPC_TARGET_CPU_H #define PPC_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUPPCState *env, target_ulong new= sp) { if (newsp) { env->gpr[1] =3D newsp; diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h index 90f9a4171e..d92153851c 100644 --- a/linux-user/riscv/target_cpu.h +++ b/linux-user/riscv/target_cpu.h @@ -1,7 +1,7 @@ #ifndef RISCV_TARGET_CPU_H #define RISCV_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPURISCVState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPURISCVState *env, target_ulong n= ewsp) { if (newsp) { env->gpr[xSP] =3D newsp; diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h index aa181ceaee..e0baa98e75 100644 --- a/linux-user/s390x/target_cpu.h +++ b/linux-user/s390x/target_cpu.h @@ -19,7 +19,7 @@ #ifndef S390X_TARGET_CPU_H #define S390X_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUS390XState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUS390XState *env, target_ulong n= ewsp) { if (newsp) { env->regs[15] =3D newsp; diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h index b0be9a2c1b..854955aa5a 100644 --- a/linux-user/sh4/target_cpu.h +++ b/linux-user/sh4/target_cpu.h @@ -19,7 +19,7 @@ #ifndef SH4_TARGET_CPU_H #define SH4_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSH4State *env, target_ulong new= sp) { if (newsp) { env->gregs[15] =3D newsp; diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 1ffc0ae9f2..8511fc3f6f 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -20,7 +20,7 @@ #ifndef SPARC_TARGET_CPU_H #define SPARC_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong n= ewsp) { if (newsp) { env->regwptr[22] =3D newsp; diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h index d1aa5824f2..dfca8d9598 100644 --- a/linux-user/tilegx/target_cpu.h +++ b/linux-user/tilegx/target_cpu.h @@ -19,7 +19,7 @@ #ifndef TILEGX_TARGET_CPU_H #define TILEGX_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUTLGState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUTLGState *env, target_ulong new= sp) { if (newsp) { env->regs[TILEGX_R_SP] =3D newsp; diff --git a/linux-user/xtensa/target_cpu.h b/linux-user/xtensa/target_cpu.h index e31efe3ea0..f436b160c4 100644 --- a/linux-user/xtensa/target_cpu.h +++ b/linux-user/xtensa/target_cpu.h @@ -4,7 +4,8 @@ #ifndef XTENSA_TARGET_CPU_H #define XTENSA_TARGET_CPU_H =20 -static inline void cpu_clone_regs(CPUXtensaState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUXtensaState *env, + target_ulong newsp) { if (newsp) { env->regs[1] =3D newsp; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f5ff6f5dc8..b9127a9601 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5534,7 +5534,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, /* we create a new CPU instance. */ new_env =3D cpu_copy(env); /* Init regs that differ from the parent. */ - cpu_clone_regs(new_env, newsp); + cpu_clone_regs_child(new_env, newsp); new_cpu =3D ENV_GET_CPU(new_env); new_cpu->opaque =3D ts; ts->bprm =3D parent_ts->bprm; @@ -5612,7 +5612,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, ret =3D fork(); if (ret =3D=3D 0) { /* Child Process. */ - cpu_clone_regs(env, newsp); + cpu_clone_regs_child(env, newsp); fork_end(1); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the = child --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297586; cv=none; d=zoho.com; s=zohoarc; b=jMPR5F3/8kSlaN1xQcrY5S3yr3GtLciKoSKtXvjmXExHqt0A1Tc2Q6Cgyp9s6UvtgLBqgXyfXDIZgdl8qVJbQM99maoINsB0nFzzwxM1mRzTizRLsHTHNmZjVI2OOAQzDNcUIG93AaVnKr85Fub3a9iCVb5MFHeOCx5I+/QpXAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297586; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zw4bkjQURlIrIACI3Vx6Yhusz3QTf2Vu+wCw/S+ioOk=; b=CWgC4nXjD8N1DVgJ/m1qNSnriFenM/uYQWQeIH4QuwZwlVXnWMYq4RvY7z5LZv2CQX3IvZb7r/RepP4VJu59PtqeYiIQNorBMlbenUuhzdLdN5yTy8yzBnvgjh5sradj3HRKLtYzydPRpHkKx9JqIXjy2A2+vr/Val0g7LYhtaY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155829758636318.917860250243393; Sun, 19 May 2019 13:26:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:52941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSO1-00028Z-5d for importer@patchew.org; Sun, 19 May 2019 16:26:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHr-0005QA-Bw for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHp-0007LN-N3 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:03 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:46766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHp-0007KQ-FI for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:01 -0400 Received: by mail-pf1-x443.google.com with SMTP id y11so6141176pfm.13 for ; Sun, 19 May 2019 13:20:01 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zw4bkjQURlIrIACI3Vx6Yhusz3QTf2Vu+wCw/S+ioOk=; b=ZPIP/XBVHL14gTd8DzkcGXeFHymuRsa1XzJo91HgZevi7HJ/izJQ/BsEm6C/iWa1qg TzAWe1I04qKgz2Q1eWu69NaRwaZ8LiG5j82XRwsGrshqCa0hAAsCIrVSJnz1v2aVZq/l LnP0PSOMsll0mZDJIBP/zjsJ6qdbJYVvKzaNR3jFaGfY5OB9DgV5K/z0nnqLWIpdX74b G2JI4jQmC5JS3NGHzhw13l+vzJgAKiSKVWvr5yADt6ioiBO78cGAhK6Zoef0SbYjUxH5 aK6mHJAfpwI7579BsQUJ1/YxyXmLefh7XclYm3SqC/shUtr6kZXsl1B8lAM62wpoGxEs 5kuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zw4bkjQURlIrIACI3Vx6Yhusz3QTf2Vu+wCw/S+ioOk=; b=lbPg4GRUxPcacgYvnA5W5WZJOHfxY90jAdtAxADGfSOFmz1vQZcgujaXqhWQN3Qoyw //3EMeHQPuYi55mJ0BzrePxCsWn3ronWFBgGJG976oYQTXMLYq+JJYCezcPg4n2TrW+p Mt6TCBdM0IjesRSb5y/rNjFEKJh/yngBLqS5t2XW1NQw74DimtcOmr2jGH0JdeOovstX pWe8Ht65znQ/wJ4bf5p1oFgBD1hDCIc3z0MJuqHBGyArstbLT8XLVvB7HS8Pc6X/6vMb lXDGSZDcXmE/2qCk9K76+aihuPFkwz09+1v3nPhk4Co2EiiQrSCp49v0npOBwH6b5rZ6 WOMw== X-Gm-Message-State: APjAAAUXKS6xfQKpRvtrEOoZA9tAik4vAIlOrwP0hvhJbjICDB2xPHLz nv+rboCCQg/U/envznDeXH/pvShJctA= X-Google-Smtp-Source: APXvYqxNXS7dkNPKfjWljNe+YNRBXhQS27Oiq7Ui/jxNyGTxkAM3gtZUFFQXPNEt2eUlqLxkC85zDA== X-Received: by 2002:a63:7413:: with SMTP id p19mr69066270pgc.259.1558297200058; Sun, 19 May 2019 13:20:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:43 -0700 Message-Id: <20190519201953.20161-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH 03/13] linux-user: Introduce cpu_clone_regs_parent X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add an empty inline function for each target, and invoke it from the proper places. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/aarch64/target_cpu.h | 4 ++++ linux-user/alpha/target_cpu.h | 4 ++++ linux-user/arm/target_cpu.h | 4 ++++ linux-user/cris/target_cpu.h | 4 ++++ linux-user/hppa/target_cpu.h | 4 ++++ linux-user/i386/target_cpu.h | 4 ++++ linux-user/m68k/target_cpu.h | 4 ++++ linux-user/microblaze/target_cpu.h | 4 ++++ linux-user/mips/target_cpu.h | 4 ++++ linux-user/nios2/target_cpu.h | 4 ++++ linux-user/openrisc/target_cpu.h | 4 ++++ linux-user/ppc/target_cpu.h | 4 ++++ linux-user/riscv/target_cpu.h | 4 ++++ linux-user/s390x/target_cpu.h | 4 ++++ linux-user/sh4/target_cpu.h | 4 ++++ linux-user/sparc/target_cpu.h | 4 ++++ linux-user/tilegx/target_cpu.h | 4 ++++ linux-user/xtensa/target_cpu.h | 4 ++++ linux-user/syscall.c | 2 ++ 19 files changed, 74 insertions(+) diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cp= u.h index abde35b104..0182bfca07 100644 --- a/linux-user/aarch64/target_cpu.h +++ b/linux-user/aarch64/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUARMState *env= , target_ulong newsp) env->xregs[0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUARMState *env) +{ +} + static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) { /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h index dc02f2234c..140a459f73 100644 --- a/linux-user/alpha/target_cpu.h +++ b/linux-user/alpha/target_cpu.h @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUAlphaState *e= nv, target_ulong newsp) env->ir[IR_A3] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUAlphaState *env) +{ +} + static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls) { env->unique =3D newtls; diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index d35c997287..3e66d5b106 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -31,6 +31,10 @@ static inline void cpu_clone_regs_child(CPUARMState *env= , target_ulong newsp) env->regs[0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUARMState *env) +{ +} + static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) { if (access_secure_reg(env)) { diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h index 9c847caaef..4da074b4fd 100644 --- a/linux-user/cris/target_cpu.h +++ b/linux-user/cris/target_cpu.h @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUCRISState *en= v, target_ulong newsp) env->regs[10] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUCRISState *env) +{ +} + static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls) { env->pregs[PR_PID] =3D (env->pregs[PR_PID] & 0xff) | newtls; diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h index b98e5a1cfe..6b323297af 100644 --- a/linux-user/hppa/target_cpu.h +++ b/linux-user/hppa/target_cpu.h @@ -31,6 +31,10 @@ static inline void cpu_clone_regs_child(CPUHPPAState *en= v, target_ulong newsp) env->iaoq_b =3D env->gr[31] + 4; } =20 +static inline void cpu_clone_regs_parent(CPUHPPAState *env) +{ +} + static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls) { env->cr[27] =3D newtls; diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h index e1c9e03490..6dbb856c52 100644 --- a/linux-user/i386/target_cpu.h +++ b/linux-user/i386/target_cpu.h @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUX86State *env= , target_ulong newsp) env->regs[R_EAX] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUX86State *env) +{ +} + #if defined(TARGET_ABI32) abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr); =20 diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index 7637a98cab..f1a53cdee5 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -29,6 +29,10 @@ static inline void cpu_clone_regs_child(CPUM68KState *en= v, target_ulong newsp) env->dregs[0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUM68KState *env) +{ +} + static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) { CPUState *cs =3D CPU(m68k_env_get_cpu(env)); diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/tar= get_cpu.h index 526b80d54d..5e285e9211 100644 --- a/linux-user/microblaze/target_cpu.h +++ b/linux-user/microblaze/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUMBState *env,= target_ulong newsp) env->regs[3] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUMBState *env) +{ +} + static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls) { env->regs[21] =3D newtls; diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h index c42660b047..d0e0b1bac0 100644 --- a/linux-user/mips/target_cpu.h +++ b/linux-user/mips/target_cpu.h @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUMIPSState *en= v, target_ulong newsp) env->active_tc.gpr[2] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUMIPSState *env) +{ +} + static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls) { env->active_tc.CP0_UserLocal =3D newtls; diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h index bec2ea79c4..01725ba004 100644 --- a/linux-user/nios2/target_cpu.h +++ b/linux-user/nios2/target_cpu.h @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUNios2State *e= nv, target_ulong newsp) env->regs[R_RET0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUNios2State *env) +{ +} + static inline void cpu_set_tls(CPUNios2State *env, target_ulong newtls) { /* diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_= cpu.h index d163ba2e26..6586951c5b 100644 --- a/linux-user/openrisc/target_cpu.h +++ b/linux-user/openrisc/target_cpu.h @@ -29,6 +29,10 @@ static inline void cpu_clone_regs_child(CPUOpenRISCState= *env, cpu_set_gpr(env, 11, 0); } =20 +static inline void cpu_clone_regs_parent(CPUOpenRISCState *env) +{ +} + static inline void cpu_set_tls(CPUOpenRISCState *env, target_ulong newtls) { cpu_set_gpr(env, 10, newtls); diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h index 34decf3876..00c9f5eb86 100644 --- a/linux-user/ppc/target_cpu.h +++ b/linux-user/ppc/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUPPCState *env= , target_ulong newsp) env->gpr[3] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUPPCState *env) +{ +} + static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls) { #if defined(TARGET_PPC64) diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h index d92153851c..4ef1b23b4f 100644 --- a/linux-user/riscv/target_cpu.h +++ b/linux-user/riscv/target_cpu.h @@ -10,6 +10,10 @@ static inline void cpu_clone_regs_child(CPURISCVState *e= nv, target_ulong newsp) env->gpr[xA0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPURISCVState *env) +{ +} + static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls) { env->gpr[xTP] =3D newtls; diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h index e0baa98e75..18e290ece8 100644 --- a/linux-user/s390x/target_cpu.h +++ b/linux-user/s390x/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUS390XState *e= nv, target_ulong newsp) env->regs[2] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUS390XState *env) +{ +} + static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls) { env->aregs[0] =3D newtls >> 32; diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h index 854955aa5a..b0e4ab23a7 100644 --- a/linux-user/sh4/target_cpu.h +++ b/linux-user/sh4/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUSH4State *env= , target_ulong newsp) env->gregs[0] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUSH4State *env) +{ +} + static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls) { env->gbr =3D newtls; diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 8511fc3f6f..52c9d8c7db 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -36,6 +36,10 @@ static inline void cpu_clone_regs_child(CPUSPARCState *e= nv, target_ulong newsp) #endif } =20 +static inline void cpu_clone_regs_parent(CPUSPARCState *env) +{ +} + static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) { env->gregs[7] =3D newtls; diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h index dfca8d9598..9577462821 100644 --- a/linux-user/tilegx/target_cpu.h +++ b/linux-user/tilegx/target_cpu.h @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUTLGState *env= , target_ulong newsp) env->regs[TILEGX_R_RE] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUTLGState *env) +{ +} + static inline void cpu_set_tls(CPUTLGState *env, target_ulong newtls) { env->regs[TILEGX_R_TP] =3D newtls; diff --git a/linux-user/xtensa/target_cpu.h b/linux-user/xtensa/target_cpu.h index f436b160c4..42e66211cf 100644 --- a/linux-user/xtensa/target_cpu.h +++ b/linux-user/xtensa/target_cpu.h @@ -15,6 +15,10 @@ static inline void cpu_clone_regs_child(CPUXtensaState *= env, env->regs[2] =3D 0; } =20 +static inline void cpu_clone_regs_parent(CPUXtensaState *env) +{ +} + static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls) { env->uregs[THREADPTR] =3D newtls; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b9127a9601..f960556bf8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5535,6 +5535,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, new_env =3D cpu_copy(env); /* Init regs that differ from the parent. */ cpu_clone_regs_child(new_env, newsp); + cpu_clone_regs_parent(env); new_cpu =3D ENV_GET_CPU(new_env); new_cpu->opaque =3D ts; ts->bprm =3D parent_ts->bprm; @@ -5630,6 +5631,7 @@ static int do_fork(CPUArchState *env, unsigned int fl= ags, abi_ulong newsp, if (flags & CLONE_CHILD_CLEARTID) ts->child_tidptr =3D child_tidptr; } else { + cpu_clone_regs_parent(env); fork_end(0); } } --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297373; cv=none; d=zoho.com; s=zohoarc; b=ehzndQUWx/I9vIR83QYDHdLQjB8CEkfpPjPUO3XJR5j9yazMGjhsw8gJSIY4hqpuwVrPAWOaUz0LAOKWPbiGTzQ/Uhu2o/jEnTcuCKwsQjvF2kgWUeNuflI6rY4QLjOSlMNmzJxwp7PXzO+y7hHQK2RtxXny6pFxuSiNwUhRwEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297373; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=T2aejSpup/jdLylt16k4iHZTGZjrzCHoXu3LKyQVTCY=; b=ndvBirSwjhtebeHl+QZsT8iyjjMF+YrHlXrBR+pRwGLBqDahnMQdPtrAC3GUdXud06YHyfiGy4DEJbRruqPgqlZZ0FpYRcCG2azlTOfnz84scFIkBBrg4VbJ6ioiIzyuVPsOs5k+rHfR6xgfB1pPEFiLweweSXAsXpfZ9v0hwS8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297373154903.6323862352135; Sun, 19 May 2019 13:22:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:52868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSKW-0007dA-Vy for importer@patchew.org; Sun, 19 May 2019 16:22:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHr-0005Qd-Oa for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHq-0007N3-PE for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:03 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:37484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHq-0007M0-Im for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:02 -0400 Received: by mail-pf1-x443.google.com with SMTP id g3so6161750pfi.4 for ; Sun, 19 May 2019 13:20:02 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T2aejSpup/jdLylt16k4iHZTGZjrzCHoXu3LKyQVTCY=; b=KjKTKbRgASqmgttgBFfUtzWbxlKpxm4MQDNPIJ2R22Ov7bs5vnerAN3YmRIwvDAddG bqHPJCoJcRe6hph8jCaQ5Km5rvWJjBPblqVikX9jU1XZEpt4YNodn+qTYNG8SG1fEwPJ nJ+33oLOrFA5TGEeoU6q9PYAE2jg7BSo/LR6gUEHlTEocQ8EyP7c13P4AgIPrEShjxA4 bMJjRWJ1Ipe11hGcVUujGtsgleqr3ZNY/EmKeDUGep6ph6P29VLDsOLIWkedi0gC+ZS6 3yIFcketU2hD2bVYdhl2TK3nQJWYAe6gtr+YRl4GL9ob94KyRqbuHc0cj5tMjCq2fPPL uOlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T2aejSpup/jdLylt16k4iHZTGZjrzCHoXu3LKyQVTCY=; b=kyEeJsVMEelzI6G3WCxdDWYJASagkqnkfPykTkgSej3uDppc6L4dt839M+J6f10GyJ phpRMNK06UjsmcHIK+uR/7QOTloZxV8c0+XoWd68Z1Vd3TZTcHFmVa0AWPC+62zTpFsG ucAC4ZSeTzB9lQF9xBsRkLme8K3xvhculB9Vu+F8eZQo1u+n0ZTSne1Q5CToEhpnNrQ5 xy80BqzCCRLiYl7HhqIULtswicCI2O396BL6ej3bE1QYQNzNNg3QLc2EVkHg4PxsLEWT lLuhynWklC0zMg2XwCUtGUJCtYAc0vwBuHKNqJtZrCgy+1pzkdJ4X5DXHh4d6EFhduLF KcpQ== X-Gm-Message-State: APjAAAVhuEpVVIogl6U0Qc4+OIqlff0fZ842I4/5Ch0teg1UCOftuNHf bRU1cUwqj8/z9lKPSMTpubbyGETW5ZA= X-Google-Smtp-Source: APXvYqzItAv2fO4PMlFSfcmgqi4+ilw/Kculx9x7s5ZhXc6b3oGtqJe8eYVMM1/K0IzPi7aTlcHMdg== X-Received: by 2002:a63:1d02:: with SMTP id d2mr71711540pgd.26.1558297201454; Sun, 19 May 2019 13:20:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:44 -0700 Message-Id: <20190519201953.20161-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH 04/13] linux-user/alpha: Set r20 secondary return value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This value is not, as far as I know, used by any linux software, but it is set by the kernel and is part of the ABI. Signed-off-by: Richard Henderson --- linux-user/alpha/target_cpu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h index 140a459f73..caadb54372 100644 --- a/linux-user/alpha/target_cpu.h +++ b/linux-user/alpha/target_cpu.h @@ -26,10 +26,12 @@ static inline void cpu_clone_regs_child(CPUAlphaState *= env, target_ulong newsp) } env->ir[IR_V0] =3D 0; env->ir[IR_A3] =3D 0; + env->ir[IR_A4] =3D 1; /* OSF/1 secondary return: child */ } =20 static inline void cpu_clone_regs_parent(CPUAlphaState *env) { + env->ir[IR_A4] =3D 0; /* OSF/1 secondary return: parent */ } =20 static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls) --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297732; cv=none; d=zoho.com; s=zohoarc; b=WbSEiYFlho2fhADFX8pagBz4A894YvSZsOFgkgnHL+0KO6+6j6GSqfplqg2pV3TXwrwiLWTyE4bof/JJshbzW9FBqHgwByL0RdT91x/ohgCpF/VZYw8xSSZRomMU7NOdKMfs2qAIyO2ASFbSKLjaMWc4F5xD7z62jxHW0V8hf7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297732; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YyTYkMwm92ztd6dS65T9tL/otWEXmt+Z9GOHdiUg3L0=; b=cy5nD6jtbLxOiErh6wNudr+yid9VQ40eP8T6azp9DYaEkll3jrVTF1zqJcVYuHhbmoiQ6WgjDAx/5ZSCdsqeiivm6yxud0wRZydQlF9NoZ9wMwHYgUCx/lq8u8kiNUXHqzqbBS0yiBcmdiJo9suvzkry77Mnh5Iraiv0hawss5M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297732208586.9823826377985; Sun, 19 May 2019 13:28:52 -0700 (PDT) Received: from localhost ([127.0.0.1]:52963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSQN-0004RB-3n for importer@patchew.org; Sun, 19 May 2019 16:28:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHt-0005TH-V6 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHs-0007Q5-Tb for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:05 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:36534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHs-0007P4-OL for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:04 -0400 Received: by mail-pl1-x641.google.com with SMTP id d21so5714097plr.3 for ; Sun, 19 May 2019 13:20:04 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YyTYkMwm92ztd6dS65T9tL/otWEXmt+Z9GOHdiUg3L0=; b=dEbW89JOxhl4goqUeqjzjcGhBl4DSTSNDfUkk5i129OTweZziUjDMNu7fWwQl2VYsv HngB4CVHSva9RTL25TZGBNizVx1gMP06JPQz3M0yiyUqjwQu8f1OhUFE3o9o8DZalUxb eYYdQKmRQeehRt7ruSCfM3jsNyHugB3eUhwQhRqw186IGJbJtj3ifRqC4dK+pQRKcnIb JOvvPakkDS13a7Ts1P4eI9yc24mV/Ee//6rUejGNKHhUPB7B5w43+JPz2aOfhcgg3FoS bGUfDOQWVNWYSJPikfXFAJbxUPtUOupbqUN4PFmdS5FeOb5TLxHgWqfdIk2CQNDuiM6M 1MUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YyTYkMwm92ztd6dS65T9tL/otWEXmt+Z9GOHdiUg3L0=; b=YOyupgBMeDi6/flw/hE6dEG5vHTeZ+pZ6x3/bMLtECv51MJpo7Eyr/OS+JeIVQwUKV 655hiCaLOQrIs9HWxQKWTA0M/0GEW0T1JhdoDZ2NNr/wRF8yFSZzwcXD8mGvTVBeW79O Bc2CPbJ3Hzuo+IOH5xQ7wumOKLURhsb9agWl0NL7pt3ZggK74d7TsJgH3a9fOmQmuAXZ zTU2OTUcb++43Le9mc9hk2Tm+eaSLM7Qg2SgM4eoRA6kQY913Kw5NpdVkNCGKmDTm9M3 gy8/AJq8+map0czLacFq4tLzNKqWnNHKtm3yTTnoZwBJPO8o+2XpxDiQ8hUhJ01sKQ3D fZyg== X-Gm-Message-State: APjAAAXtjhF5NvqNPJyje8Cyi0jE7t66Qn6wBJG1+ZvvuLfjq3QRrNhv xh6UYNbPNjFTlPjXjIxElvmK3uu8vIk= X-Google-Smtp-Source: APXvYqwzW2cNxFDZhE++oPT2bPEhqjlxfisS8zaqhPhgcdQrIqWDEtavGz4Ap4Mj6la5RIxk/12sMA== X-Received: by 2002:a17:902:8214:: with SMTP id x20mr49272305pln.308.1558297202809; Sun, 19 May 2019 13:20:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:45 -0700 Message-Id: <20190519201953.20161-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH 05/13] target/sparc: Define an enumeration for accessing env->regwptr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index f31e8535df..f0ac3ac086 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -31,6 +31,39 @@ =20 /*#define EXCP_INTERRUPT 0x100*/ =20 +/* Windowed register indexes. */ +enum { + WREG_O0, + WREG_O1, + WREG_O2, + WREG_O3, + WREG_O4, + WREG_O5, + WREG_O6, + WREG_O7, + + WREG_L0, + WREG_L1, + WREG_L2, + WREG_L3, + WREG_L4, + WREG_L5, + WREG_L6, + WREG_L7, + + WREG_I0, + WREG_I1, + WREG_I2, + WREG_I3, + WREG_I4, + WREG_I5, + WREG_I6, + WREG_I7, + + WREG_SP =3D WREG_O6, + WREG_FP =3D WREG_I6, +}; + /* trap definitions */ #ifndef TARGET_SPARC64 #define TT_TFAULT 0x01 --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297684; cv=none; d=zoho.com; s=zohoarc; b=DSm2O84S1IBlFTSgREoMDpEmRwQBtwSZ77rBWTcxcWObpW/F+o+F2U8i+1kYLcDW6VpWQyaJeR+ey64/OUZaxCC48ikBK6SwiR1VVp1Uk0xA9b0Dy3VeS9RPwGWZMcPeLmqBgbK8STg82/xRrcu25LrmIjCpSXADR0BmWeoZ1e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297684; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+/qY9GymWVw9Tgqaah5CkydYCEaLw/iJ0Pj5fe5qwlo=; b=clI3iDXOMgJOlgsYGiusaTGiF2dso4xyTjHv7IKDC3VLnfO1n0zk/PvNav3NL1WLkJEAPMx+bwzlUHKzLXp/0IHW/v1a6M1xTzVf3eUlBuxbR3UZnSxWLC+SHnb5tMFEQlfJtrbILEn8mULwBRS/7iwEEaP80OFmm13gt5Z70yc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297684706810.0237268256276; Sun, 19 May 2019 13:28:04 -0700 (PDT) Received: from localhost ([127.0.0.1]:52957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSPP-0003fc-85 for importer@patchew.org; Sun, 19 May 2019 16:27:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHu-0005UU-OW for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHt-0007Qx-GV for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:06 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHt-0007Pg-9v for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:05 -0400 Received: by mail-pg1-x542.google.com with SMTP id t22so5716038pgi.10 for ; Sun, 19 May 2019 13:20:05 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+/qY9GymWVw9Tgqaah5CkydYCEaLw/iJ0Pj5fe5qwlo=; b=a9sy3aEgGCerhkMJt5FtPjNy7lDtVevoCaD8WJaq57V0+wqBFkdo/A6n2/hHia9M+V xH7kf4rUMrVMQ0zDF232WAkao9E6eTgZ4IyVnZ0b+eBeIfIGmH5Ey5Xri5hkNWMSz/7O /iuC+UY6g5CexOSaNru9vKFlj8NGNX3/dAvfwoEhnZyQQ5Td2UrSAV7RubpyvFDmsdBi TKiKA0Ir6izpIDP/kPkpVROGWHKXRPjbl+F91Y2aGgI63mWuFrhAMCxQ4rJPljHHL4sz Ih9TpocUJCLF2bAm5mTdl/zw4lNj5s7HzAFsd1LXbuEgiuhikDhsxrNVWxKq+C9v+jtB kk2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+/qY9GymWVw9Tgqaah5CkydYCEaLw/iJ0Pj5fe5qwlo=; b=OcAecolrGKRCKrggDSlUUiulZ0Dhl9mjJ28WAPmbkpKR/UjO8COLdiJMIQNo4F/OuR CE322NVQ4jTYvBDXzHwFdJ1tLX7ti+SxzoLxOdmsTh8i60H3Cxi5YEKgDbpu4MdTQ2fd WJVlAqMOGDovc1pDRo4zXYcJn1tz1WjujWm+j6R+Gx3pA/NElEGccg5ym0eTWNB8ag5l z0vMpLuOYNriHdhXk2hjtl4CXMRCaIMLVH2oX0U36P8Tz2X6IRnUYD7MGNT8R/1xhGWm iD1Ve3P3tDxrmyTKROTk6Bn9OID2ZRnVqxzsgg+qQLujrD8TpBLfzDzR8bh3KqjzvxCc tN2A== X-Gm-Message-State: APjAAAXuf9SZGXFnTIU76iXPr017Vb3pCsym9Gs3xEX17wjDXDc1Z4eW o1NVITNsFRQ6Z70+Oq900BVlhTSK1Ew= X-Google-Smtp-Source: APXvYqzC7MhZ/rMiTFjTKKxwHghN7ynVKKx0Dl5w2dCPtrPxKkrEl1KGcOPs4OiaWkrEkA2uxR3kjA== X-Received: by 2002:a63:d652:: with SMTP id d18mr55026317pgj.112.1558297204034; Sun, 19 May 2019 13:20:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:46 -0700 Message-Id: <20190519201953.20161-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH 06/13] linux-user/sparc: Use WREG constants in sparc/target_cpu.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This fixes a naming bug wherein we used "UREG_FP" to access the stack pointer. OTOH, the "UREG_FP" constant was also defined incorrectly such that it *did* reference the stack pointer. Note that the kernel legitimately uses the name "FP", because it utilizes the rolled stack window in processing the system call. Signed-off-by: Richard Henderson --- linux-user/sparc/target_cpu.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 52c9d8c7db..2c80db4889 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -45,15 +45,9 @@ static inline void cpu_set_tls(CPUSPARCState *env, targe= t_ulong newtls) env->gregs[7] =3D newtls; } =20 -#ifndef UREG_I6 -#define UREG_I6 6 -#endif -#ifndef UREG_FP -#define UREG_FP UREG_I6 -#endif - static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state) { - return state->regwptr[UREG_FP]; + return state->regwptr[WREG_SP]; } + #endif --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297882; cv=none; d=zoho.com; s=zohoarc; b=m5D9W3DCy2B9Vym/0WQlykQrbsa77ejNihLAANaHN1Nda2ybHF+3HFCJsqPf0nBO1q13wg1EzV0UlgKLYoasPYC2tA84BtpTfAMOWvEUZTeaARq+R+mNYCVLnKzIyJLATA3Ks2O5ieE4zlUB61YKkSbKY3vov6StaYmxNWgjWPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297882; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ad7p0XpmVmGXkoTgniD57oGcto4g8MS55uU7nmfGDcA=; b=QKwrM/KRRxcO830CcpeKqvjkSQVg6VD20VIcRkK9pZS38vBeWplUaOFToU1Lor4/Su+Uda83bhOm1ujeFKH0+sVrf0r0lnTgNTi8MkFzWfoPAMxcq8t7xhgKoY0KJ/8BP/sUSmESO0l6kI6NJj3qccXYnJ+KL5JPSp/xe5lhFRE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297882871509.75494952882434; Sun, 19 May 2019 13:31:22 -0700 (PDT) Received: from localhost ([127.0.0.1]:53019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSSl-0006JB-NS for importer@patchew.org; Sun, 19 May 2019 16:31:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHw-0005Za-QZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHv-0007UJ-0z for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:08 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36535) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHu-0007Rf-Oe for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:06 -0400 Received: by mail-pl1-x642.google.com with SMTP id d21so5714122plr.3 for ; Sun, 19 May 2019 13:20:06 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ad7p0XpmVmGXkoTgniD57oGcto4g8MS55uU7nmfGDcA=; b=M/84nIqaNsYvKYx9qrII9u/weiqN2RS9hsjBx4qSLvSJl9sHHHO+kpurT1ntc70svB HzRbGjgGJXkfNqieiD0APNM6f2F/5DRkElyOCb7YsoT/FcQtvdBto4sYo+v1fMZn9UuP planBi3jDKfNO5IQjQyIxMOw++OjCvMZ1PxDperXokTzDVJloMKN0TqL11YvK00jYHib m2qMc0MYekAHL1v1KIkvj88SyXWF5LsO9gVYFgZtVnFivPaMPu7AVNu8mqjMRycoJEUb 7rrFEJtFCwL1g19QnYMsfNJ9FNvHBRsDp5UnUOtpa1GXyYsGUwAdIMJMoSHtNBnKjNMU o/9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ad7p0XpmVmGXkoTgniD57oGcto4g8MS55uU7nmfGDcA=; b=XRPJxz5KGe4WjVKIGshNV7jaRcYDU27gc/rgSsCW/gGoQ4wvRXADRVu07yBQivylTj JbUJg3UTDAx7pTi3Gf0STbi/BNnO6zNSlTMupuREwAIAFXlyIWgc2YJqKX6p16a5NUQ0 wAeZEZG2lxppZk8DTOQX337ib4POmlfimIqg7XwmusEmsT//AYSgpfyXxe/Xnwe7JyVf Gf0q/HXZjO2GdL+pUl2oSCggC9Y1uJYuEEj0/iUVcP+AKpDFJ8PDn7Wyy2Z3tgvBW2yj Edaj4wOfv+5iFFKnqvQKKWmdr2wZ70sfGW8a/vX6zML4d6lNhQxux18E0r35kRMLTh1V 9AtA== X-Gm-Message-State: APjAAAV0Xx5ODNjZwcWjkaB/jRUpWs7WD6C5+exh8p9uDBeKgQ1wlVNA Pc/QjIPvjcJzbhTrlGNejzTyf5xCGUM= X-Google-Smtp-Source: APXvYqxMeMwBQXMdF4j55LQ/eG8j93MV3nAipyBW3OVyqWcaJWIApqE+fPvPKARkVhCjmLKqhtbUpg== X-Received: by 2002:a17:902:8d94:: with SMTP id v20mr2292784plo.99.1558297205244; Sun, 19 May 2019 13:20:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:47 -0700 Message-Id: <20190519201953.20161-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH 07/13] linux-user/sparc: Use WREG constants in sparc/signal.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Remove the incorrectly defined UREG constants. Maddeningly, in some cases we used the correct constant getting the env register wrong, and in other cases we used the incorrect constant getting the env register right. In the case of getcontext/setcontext, we are aided by the fact that the "other" constant, e.g. SPARC_MC_O0, is correct. So we can easily guess that the WREG_* constant on the other side should also be O0. Signed-off-by: Richard Henderson --- linux-user/sparc/signal.c | 96 +++++++++++++-------------------------- 1 file changed, 32 insertions(+), 64 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index ead169fbaa..243f237528 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -104,20 +104,6 @@ struct target_rt_signal_frame { qemu_siginfo_fpu_t fpu_state; }; =20 -#define UREG_O0 16 -#define UREG_O6 22 -#define UREG_I0 0 -#define UREG_I1 1 -#define UREG_I2 2 -#define UREG_I3 3 -#define UREG_I4 4 -#define UREG_I5 5 -#define UREG_I6 6 -#define UREG_I7 7 -#define UREG_L0 8 -#define UREG_FP UREG_I6 -#define UREG_SP UREG_O6 - static inline abi_ulong get_sigframe(struct target_sigaction *sa,=20 CPUSPARCState *env, unsigned long framesize) @@ -159,30 +145,12 @@ setup___siginfo(__siginfo_t *si, CPUSPARCState *env, = abi_ulong mask) __put_user(env->gregs[i], &si->si_regs.u_regs[i]); } for (i=3D0; i < 8; i++) { - __put_user(env->regwptr[UREG_I0 + i], &si->si_regs.u_regs[i+8]); + __put_user(env->regwptr[WREG_O0 + i], &si->si_regs.u_regs[i+8]); } __put_user(mask, &si->si_mask); return err; } =20 -#if 0 -static int -setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,= */ - CPUSPARCState *env, unsigned long mask) -{ - int err =3D 0; - - __put_user(mask, &sc->sigc_mask); - __put_user(env->regwptr[UREG_SP], &sc->sigc_sp); - __put_user(env->pc, &sc->sigc_pc); - __put_user(env->npc, &sc->sigc_npc); - __put_user(env->psr, &sc->sigc_psr); - __put_user(env->gregs[1], &sc->sigc_g1); - __put_user(env->regwptr[UREG_O0], &sc->sigc_o0); - - return err; -} -#endif #define NF_ALIGNEDSZ (((sizeof(struct target_signal_frame) + 7) & (~7))) =20 void setup_frame(int sig, struct target_sigaction *ka, @@ -221,20 +189,20 @@ void setup_frame(int sig, struct target_sigaction *ka, } =20 for (i =3D 0; i < 8; i++) { - __put_user(env->regwptr[i + UREG_L0], &sf->ss.locals[i]); + __put_user(env->regwptr[i + WREG_L0], &sf->ss.locals[i]); } for (i =3D 0; i < 8; i++) { - __put_user(env->regwptr[i + UREG_I0], &sf->ss.ins[i]); + __put_user(env->regwptr[i + WREG_I0], &sf->ss.ins[i]); } if (err) goto sigsegv; =20 /* 3. signal handler back-trampoline and parameters */ - env->regwptr[UREG_FP] =3D sf_addr; - env->regwptr[UREG_I0] =3D sig; - env->regwptr[UREG_I1] =3D sf_addr + + env->regwptr[WREG_FP] =3D sf_addr; + env->regwptr[WREG_I0] =3D sig; + env->regwptr[WREG_I1] =3D sf_addr + offsetof(struct target_signal_frame, info); - env->regwptr[UREG_I2] =3D sf_addr + + env->regwptr[WREG_I2] =3D sf_addr + offsetof(struct target_signal_frame, info); =20 /* 4. signal handler */ @@ -242,11 +210,11 @@ void setup_frame(int sig, struct target_sigaction *ka, env->npc =3D (env->pc + 4); /* 5. return to kernel instructions */ if (ka->ka_restorer) { - env->regwptr[UREG_I7] =3D ka->ka_restorer; + env->regwptr[WREG_I7] =3D ka->ka_restorer; } else { uint32_t val32; =20 - env->regwptr[UREG_I7] =3D sf_addr + + env->regwptr[WREG_I7] =3D sf_addr + offsetof(struct target_signal_frame, insns) - 2 * 4; =20 /* mov __NR_sigreturn, %g1 */ @@ -284,7 +252,7 @@ long do_sigreturn(CPUSPARCState *env) sigset_t host_set; int i; =20 - sf_addr =3D env->regwptr[UREG_FP]; + sf_addr =3D env->regwptr[WREG_SP]; trace_user_do_sigreturn(env, sf_addr); if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) { goto segv_and_exit; @@ -316,7 +284,7 @@ long do_sigreturn(CPUSPARCState *env) __get_user(env->gregs[i], &sf->info.si_regs.u_regs[i]); } for (i=3D0; i < 8; i++) { - __get_user(env->regwptr[i + UREG_I0], &sf->info.si_regs.u_regs[i+8= ]); + __get_user(env->regwptr[i + WREG_O0], &sf->info.si_regs.u_regs[i+8= ]); } =20 /* FIXME: implement FPU save/restore: @@ -433,7 +401,7 @@ void sparc64_set_context(CPUSPARCState *env) abi_ulong fp, i7, w_addr; unsigned int i; =20 - ucp_addr =3D env->regwptr[UREG_I0]; + ucp_addr =3D env->regwptr[WREG_O0]; if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) { goto do_sigsegv; } @@ -443,7 +411,7 @@ void sparc64_set_context(CPUSPARCState *env) if ((pc | npc) & 3) { goto do_sigsegv; } - if (env->regwptr[UREG_I1]) { + if (env->regwptr[WREG_O1]) { target_sigset_t target_set; sigset_t set; =20 @@ -474,19 +442,19 @@ void sparc64_set_context(CPUSPARCState *env) __get_user(env->gregs[5], (&(*grp)[SPARC_MC_G5])); __get_user(env->gregs[6], (&(*grp)[SPARC_MC_G6])); __get_user(env->gregs[7], (&(*grp)[SPARC_MC_G7])); - __get_user(env->regwptr[UREG_I0], (&(*grp)[SPARC_MC_O0])); - __get_user(env->regwptr[UREG_I1], (&(*grp)[SPARC_MC_O1])); - __get_user(env->regwptr[UREG_I2], (&(*grp)[SPARC_MC_O2])); - __get_user(env->regwptr[UREG_I3], (&(*grp)[SPARC_MC_O3])); - __get_user(env->regwptr[UREG_I4], (&(*grp)[SPARC_MC_O4])); - __get_user(env->regwptr[UREG_I5], (&(*grp)[SPARC_MC_O5])); - __get_user(env->regwptr[UREG_I6], (&(*grp)[SPARC_MC_O6])); - __get_user(env->regwptr[UREG_I7], (&(*grp)[SPARC_MC_O7])); + __get_user(env->regwptr[WREG_O0], (&(*grp)[SPARC_MC_O0])); + __get_user(env->regwptr[WREG_O1], (&(*grp)[SPARC_MC_O1])); + __get_user(env->regwptr[WREG_O2], (&(*grp)[SPARC_MC_O2])); + __get_user(env->regwptr[WREG_O3], (&(*grp)[SPARC_MC_O3])); + __get_user(env->regwptr[WREG_O4], (&(*grp)[SPARC_MC_O4])); + __get_user(env->regwptr[WREG_O5], (&(*grp)[SPARC_MC_O5])); + __get_user(env->regwptr[WREG_O6], (&(*grp)[SPARC_MC_O6])); + __get_user(env->regwptr[WREG_O7], (&(*grp)[SPARC_MC_O7])); =20 __get_user(fp, &(ucp->tuc_mcontext.mc_fp)); __get_user(i7, &(ucp->tuc_mcontext.mc_i7)); =20 - w_addr =3D TARGET_STACK_BIAS+env->regwptr[UREG_I6]; + w_addr =3D TARGET_STACK_BIAS + env->regwptr[WREG_FP]; if (put_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), abi_ulong) !=3D 0) { goto do_sigsegv; @@ -534,7 +502,7 @@ void sparc64_get_context(CPUSPARCState *env) target_sigset_t target_set; sigset_t set; =20 - ucp_addr =3D env->regwptr[UREG_I0]; + ucp_addr =3D env->regwptr[WREG_O0]; if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) { goto do_sigsegv; } @@ -580,16 +548,16 @@ void sparc64_get_context(CPUSPARCState *env) __put_user(env->gregs[5], &((*grp)[SPARC_MC_G5])); __put_user(env->gregs[6], &((*grp)[SPARC_MC_G6])); __put_user(env->gregs[7], &((*grp)[SPARC_MC_G7])); - __put_user(env->regwptr[UREG_I0], &((*grp)[SPARC_MC_O0])); - __put_user(env->regwptr[UREG_I1], &((*grp)[SPARC_MC_O1])); - __put_user(env->regwptr[UREG_I2], &((*grp)[SPARC_MC_O2])); - __put_user(env->regwptr[UREG_I3], &((*grp)[SPARC_MC_O3])); - __put_user(env->regwptr[UREG_I4], &((*grp)[SPARC_MC_O4])); - __put_user(env->regwptr[UREG_I5], &((*grp)[SPARC_MC_O5])); - __put_user(env->regwptr[UREG_I6], &((*grp)[SPARC_MC_O6])); - __put_user(env->regwptr[UREG_I7], &((*grp)[SPARC_MC_O7])); + __put_user(env->regwptr[WREG_O0], &((*grp)[SPARC_MC_O0])); + __put_user(env->regwptr[WREG_O1], &((*grp)[SPARC_MC_O1])); + __put_user(env->regwptr[WREG_O2], &((*grp)[SPARC_MC_O2])); + __put_user(env->regwptr[WREG_O3], &((*grp)[SPARC_MC_O3])); + __put_user(env->regwptr[WREG_O4], &((*grp)[SPARC_MC_O4])); + __put_user(env->regwptr[WREG_O5], &((*grp)[SPARC_MC_O5])); + __put_user(env->regwptr[WREG_O6], &((*grp)[SPARC_MC_O6])); + __put_user(env->regwptr[WREG_O7], &((*grp)[SPARC_MC_O7])); =20 - w_addr =3D TARGET_STACK_BIAS+env->regwptr[UREG_I6]; + w_addr =3D TARGET_STACK_BIAS + env->regwptr[WREG_FP]; fp =3D i7 =3D 0; if (get_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), abi_ulong) !=3D 0) { --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297603; cv=none; d=zoho.com; s=zohoarc; b=CVLmUe6TMB/DM4Qp/TGGcSpi4O8NL4/6cITDxqIs0KmeY1fek11jdLg1qDCwB4GxiCBqTalfKW3sd66uo1YTYIHqe0jzZD3oOll6nh97IA53JAr/H6njfSzcuJtc5kl+s8UJSGuDmlgiMByTZYZHrs8BS09PofeJFZ0mCbOTUL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297603; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=POxFIOq98+f7SlQ+Qq4/1i4zdlqYdJgB+ksVYwShoNE=; b=PL+rLUPtApZnYjgF/sbDxc1shko7fwvBlI7UxG7qwNbTGrm2p8ApPpN0dmGRI/Lh7ycO02+bdcXT7daoHRnGpZX/O9r6v+MS19Cx6SZinUMvb35UihLMA54AsULXACGmaVhLGEsNYtR+LP9uipsHycAZ22dpVS5atmkiGkdYjlM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297603133285.89186872680034; Sun, 19 May 2019 13:26:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:52949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSOH-0002XQ-Si for importer@patchew.org; Sun, 19 May 2019 16:26:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSHw-0005Zb-Rq for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHv-0007VW-Nb for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:08 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHv-0007U9-Eh for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:07 -0400 Received: by mail-pg1-x543.google.com with SMTP id t1so4312941pgc.2 for ; Sun, 19 May 2019 13:20:07 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=POxFIOq98+f7SlQ+Qq4/1i4zdlqYdJgB+ksVYwShoNE=; b=X6fHeKMuPiTfBuayn2n8h1uxIIh2MAHKNf+IDOTzogrsS7fSUfxRFCo60t02Dp+IGR 2uGTqjHG+SmG1AWU9ij3988LS2vlCQNTvThjRm3IAABv7Go7Uzvg3oI2wWKsyr9XLPOF JiFM4mw6UwQXbMoozGgcL5bEqfA+L//akEaGia/NniMliiHbDdvm3ApR0+4li1NHIu+D jbxAveIMFxA0DPPc8S8Y3AzzizX3Tet53UmwoB8T1NLWAJ9Z+sCw51UswNVOf/Qw4biO Tq0ZTgJ2ii470/JkasUsQ3H1cFx+9UTcPJDQ5/USJdLXiMi8GLgmtubCnIVFdlwvhT/w s+uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=POxFIOq98+f7SlQ+Qq4/1i4zdlqYdJgB+ksVYwShoNE=; b=B6juy526ERg0BTxRUaYu6pWE5pyeB49t2w8tolSI6ZEgUTiDsIACZ1aiZWNS2CcsdF il5LmS7hvbC6701jLNopH7kZGpr7hOh0+0XzpgxYofdTIj2Jl78zbAJeS0UCbDuQvTJg pxw1utZflTuBjKfoz+dYNwmM7Lpp0aJmZRkSQ9oVazCF7QV9A/AfrryL8UU2+BFc36XK uJCJdljd1e540ft1e/NY1biup5R4j9SioYzZ1WUombrzFGo94Fa7mQnU4qUOeYyQ8ZfI gMupenljUwGugmtqbgdXPbqa0hfRmGQ4/43+ElqZuQu9uQnEG3PpgINWVTltLahshk9H Mj/A== X-Gm-Message-State: APjAAAW5rGWf+Wt5LWLt1Y0e0txO/3ZxbKygL1/v6SSFut1KtCIxTIkw zzGqwedu+55qXQeu+lOEZWjb+hV9z2g= X-Google-Smtp-Source: APXvYqxi0omESB0dgC987/mSzbNezeqTbWDRhKm6vwOjslMpfVaWVTuV0mqKIiwiTUv/InY9bTAHFg== X-Received: by 2002:a65:5244:: with SMTP id q4mr69698053pgp.79.1558297206298; Sun, 19 May 2019 13:20:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:48 -0700 Message-Id: <20190519201953.20161-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH 08/13] linux-user/sparc: Fix cpu_clone_regs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We failed to set the secondary return value in %o1 we failed to advance the PC past the syscall, we failed to adjust regwptr into the new structure, we stored the stack pointer into the wrong register. Signed-off-by: Richard Henderson --- linux-user/sparc/target_cpu.h | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 2c80db4889..a81f8216b7 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -22,22 +22,39 @@ =20 static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong n= ewsp) { - if (newsp) { - env->regwptr[22] =3D newsp; - } - /* syscall return for clone child: 0, and clear CF since - * this counts as a success return value. + /* + * After cpu_copy, env->regwptr is pointing into old_env. + * Update the new cpu to use its own register window. */ - env->regwptr[0] =3D 0; + env->regwptr =3D env->regbase + (env->cwp * 16); + + /* Set a new stack, if requested. */ + if (newsp) { + /* ??? The kernel appears to copy one stack frame to the new stack= . */ + /* ??? The kernel force aligns the stack. */ + env->regwptr[WREG_SP] =3D newsp; + } + + /* + * Syscall return for clone child: %o0 =3D 0 and clear CF since + * this counts as a success return value. %o1 =3D 1 to indicate + * this is the child. Advance the PC past the syscall. + */ + env->regwptr[WREG_O0] =3D 0; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) env->xcc &=3D ~PSR_CARRY; #else env->psr &=3D ~PSR_CARRY; #endif + env->regwptr[WREG_O1] =3D 1; + env->pc =3D env->npc; + env->npc =3D env->npc + 4; } =20 static inline void cpu_clone_regs_parent(CPUSPARCState *env) { + /* Set the second return value for the parent: %o1 =3D 0. */ + env->regwptr[WREG_O1] =3D 0; } =20 static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558298177; cv=none; d=zoho.com; s=zohoarc; b=luhCUnbChCRFuxf+JbLXPTZseD0l8um6szs5hYvP8b/SbW2klwSgNEQuFuekUi92lhs6JrBXiaEyb+OlE3MFHGQTjJRjgL7xSyhuwsyZxXGwkYke+Rc/RWQeA+Jsyo4mOjfZaDxILOIhXNUkqst4QfESvweyfnqvor6nx8KkXC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558298177; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EslukgOgrXKOg9aqYU0CsDWXr7O+egog9zUh9mSRURk=; b=Qkk8uZgrW4wl9wJltuRv/GnqAjVd4vkZiUKCs0udDPrM7A/SnxKYrqc2dvYOt5ZIO5D8j9ucz41tevBGmD/oeIH4oWdhDIwY6ljNvaWLFPywFWOTpUzAZa4vw5HCUeXc3hgNP0+Xn97RtTTRbwgfonUDQ9TFDpqBEr0SXySpBow= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558298177294368.17704680669533; Sun, 19 May 2019 13:36:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:53092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSXS-0001Jo-1X for importer@patchew.org; Sun, 19 May 2019 16:36:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSI0-0005gT-PR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSHy-0007Zc-Q8 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:12 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:33480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHw-0007Vz-RC for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:10 -0400 Received: by mail-pl1-x644.google.com with SMTP id y3so5725575plp.0 for ; Sun, 19 May 2019 13:20:08 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EslukgOgrXKOg9aqYU0CsDWXr7O+egog9zUh9mSRURk=; b=spOuULvmqJdWnGZ+oymBAv8/exyZU1Oz1CqCtk0l1Cjv6ARICQX/FmE+lISMPzTh3T GdWzVEKu1aXWInJrjsUqCrYoVAsCDUWn1w8zcjlexDk64VYnAmpUzMWd7PplXPbAYzi8 EX+CjtHpjMlj36tsdNrtMQcUwn3T1HIT09g6cG0SqabZdyZ75qRBbC2ZolhkSLcniiyP jpALldhlfXNOc8yFWpFka4vwYRlo5LZcmVSnScAYOCXZz5QL/EAl370pUg4eHFfq4+Re qpVfr8NMFKvY77B4Dieib+Tx0Alk68+Lk53+KV50PBHaP9BjlMpS/fsb3Zihi+Jb/Sq6 ZaYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EslukgOgrXKOg9aqYU0CsDWXr7O+egog9zUh9mSRURk=; b=GTAxNTmnSZwgWRrOEZNy+HmrHLTj202N2ZFVUEe2Dv+8j0fi8KHIupGgGV74NJPwBr fsaM7sQTJmt+7nXCr7dUT2pLwtw3rBqlbNvEfkJgutSC08/U/tv2OZoKKnOGkb5LHEM2 7jmUvBG3tImqrZUrwzYeTklDtRl6I1hiQ4OBz8SX1rT4A7PKnrjK20z95MMKLv+c5eN/ xJNbn/EBfC99NTSoIRCRzoQkAlGKfgWmoslrx0uABS9uAKUrQ7DKaag7CG34vWlxM93q /MPc6VvvOpVOwa1Cadaal9Iiq1HyqThzEVJvVRYy5dZuTHahaT9OEEH3DgMIk78uc79V CKAw== X-Gm-Message-State: APjAAAVu+Sjla2CSQz1+JCOfj0ZSoGtUA/CdA4ftixD6KybCr6zrU4ue /aKUEvwbGwSmmXya8MUENtnAWPhqGp0= X-Google-Smtp-Source: APXvYqxTN5bWSUnvvpcTnivRh7ZWJWJ4vbwtJIVtvJ8Vg1ruiplEbRnWE5msBXSSzQZp4fcnNulEBw== X-Received: by 2002:a17:902:8609:: with SMTP id f9mr15303251plo.252.1558297207346; Sun, 19 May 2019 13:20:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:49 -0700 Message-Id: <20190519201953.20161-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH 09/13] linux-user/sparc: Flush register windows before clone/fork/vfork X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As seen as the very first instruction of sys_clone in the kernel. Ideally this would be done in or before cpu_copy, and not with a separate explicit test vs the syscall number, but this is a more minimal solution. Signed-off-by: Richard Henderson --- linux-user/sparc/cpu_loop.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 9e357229c0..0816da6fa1 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -169,6 +169,18 @@ void cpu_loop (CPUSPARCState *env) case 0x110: case 0x16d: #endif + /* + * Before copying/adjusting registers for parent/child, + * flush the register windows to the stack. + */ + switch (env->gregs[1]) { + case TARGET_NR_fork: + case TARGET_NR_vfork: + case TARGET_NR_clone: + flush_windows(env); + break; + } + ret =3D do_syscall (env, env->gregs[1], env->regwptr[0], env->regwptr[1], env->regwptr[2], env->regwptr[3], --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558298042; cv=none; d=zoho.com; s=zohoarc; b=XH1P2723BIP6cbWyc860oHjMLCNjGGJKGlijx/tr1w+PVdlTrgolyziv6/Z66ZbQl7YMqyPDkve/CFiIhFWimHhnMq46U4Ykk9EOV7HwiFDwr+KyMNiZKzhQHSQdp00J1oO/p08pRNkS4ezJL3pYlO37N0CLCc1IKQx317b6Bsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558298042; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OghAJHs3fOQNasKs983B96RGcVieroO+wnBU19gV5SI=; b=DVdKZWVyesmNg1/+P+UAE3FkLXiPiOCKS1KbjwQ0VxV5tyHRX7rv4QDKbmmcuKGA10xXIwK8tvA7l4+eVW4+I2dvdZlByge6PkP5pC13D7cKE9T2h7hJvgUNvS45obYPytfyDk39opNJyqTclfpiPyfBSvq2C2wAFxTbpti1ZkQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558298042221975.5404966243113; Sun, 19 May 2019 13:34:02 -0700 (PDT) Received: from localhost ([127.0.0.1]:53035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSUw-0007uA-CQ for importer@patchew.org; Sun, 19 May 2019 16:33:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSI2-0005k9-Da for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSI0-0007eL-8N for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:13 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36536) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHy-0007Xh-Mp for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:10 -0400 Received: by mail-pl1-x643.google.com with SMTP id d21so5714155plr.3 for ; Sun, 19 May 2019 13:20:09 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OghAJHs3fOQNasKs983B96RGcVieroO+wnBU19gV5SI=; b=PgTc8tb0uGJBUQ91uzPmnpK2qR3CSaZGEtdGDqHMDUErDl+tJkM/06tHP9tg8x8Ri3 1rTNFUyqAV+ummikZJvkb0txOt7YM7xcSse0YYY3eso7sFXa1eQN7g5WvrMpkG+KCdc+ R/PrzFOolMpayQgBQEqL2XnD+3N3GrAcP46P0bRDMXGq2Mtby4pCO3d6oFT851VK5G41 pk1daf4L8E/i+kKgJ/4tclpf2af+IVgO+KViNEsgzmqFAjix6vqnXt0zA2JOuqrCd6x4 lXg9SCG0MmdNyFk0OdRMHuoJrD9Cvue9Zdow+fR7oHA6U4j3V8i8aAOd3RWpdwIPTWxP 9lHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OghAJHs3fOQNasKs983B96RGcVieroO+wnBU19gV5SI=; b=pwjbkA3iBZ17ez1gW5xNp8CpuItUldRK1XVCUS/dixNWuFEd9n+qWswuyCwrNTkM7X G0KEN/7Jz0UTJ2C986qvQLv6uU/bPqVhn0StyrF0muBinKKEmY4UvKgpEOu0XIULzsnH ptlUFat0ZoaqWARYyhxaR2Sgsrv5RwzoLWEoYsIFdA7z0EeIFHbubgq++bpo8korbDn0 R9l1SGn7Y2jhYzZf0vylTR3ebgmhUfRXyEvXknt0AVURjT3wACzTNqmYqEGHUiJhzXfK LBzlWEUG73kZhri6xs0aWqjsDDoLa2wlD6HLHbgnKjK5Qj2i4b5PueeGYwOdAvXQrOT0 HCJg== X-Gm-Message-State: APjAAAUoC6z/oZZsruRplR+vkCo1uqiYwK+zWEMCGLFhXwahzO3yGAsk 3A9rukwcIMfA67q7EemGEkdPFG9ZrZM= X-Google-Smtp-Source: APXvYqx2hVtHNMo+/6ciJEVghnkVOPLzq5OvLbR4X3DhK2aFNt6360NbTZICNdnC7i3Kg3ioiCAQUw== X-Received: by 2002:a17:902:ac90:: with SMTP id h16mr8998490plr.162.1558297208369; Sun, 19 May 2019 13:20:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:50 -0700 Message-Id: <20190519201953.20161-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH 10/13] scripts/qemu-binfmt-conf: Update for sparc64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Also note that we were missing the qemu_target_list entry for plain sparc; fix that at the same time. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Tested-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index b5a16742a1..9f1580a91c 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -1,8 +1,8 @@ #!/bin/sh # Enable automatic program execution by the kernel. =20 -qemu_target_list=3D"i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64l= e m68k \ -mips mipsel mipsn32 mipsn32el mips64 mips64el \ +qemu_target_list=3D"i386 i486 alpha arm armeb sparc sparc32plus sparc64 \ +ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \ sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \ microblaze microblazeel or1k x86_64" =20 @@ -38,6 +38,10 @@ sparc32plus_magic=3D'\x7fELF\x01\x02\x01\x00\x00\x00\x00= \x00\x00\x00\x00\x00\x00\x sparc32plus_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\x= ff\xff\xff\xff\xfe\xff\xff' sparc32plus_family=3Dsparc =20 +sparc64_magic=3D'\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x= 00\x02\x00\x2b' +sparc64_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x= ff\xff\xff\xfe\xff\xff' +sparc64_family=3Dsparc + ppc_magic=3D'\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x= 02\x00\x14' ppc_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\x= ff\xff\xfe\xff\xff' ppc_family=3Dppc --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558297888; cv=none; d=zoho.com; s=zohoarc; b=l8Yo6cBy3553/f52ojuFvRg4FnHRFM9bCW0D0U6loASoZ8qS9zqJqckF8arj8twTOBzIImA9AUqm6wYosj/NrrqPWhd1HaDzAoIYoAM3vMwL327X6igOl6r7Eo+1fJAySgjDeoaqQ4VFLXL768CD9m1Pqcm5INs3SOxytejH/mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558297888; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IbY6I9DzAmMV/VMKU0boKo5CQjvFhhAqBWPLdeOiiQg=; b=OF1tprLujv3aHv7cq1ZESJ1F2L5h5lYBfL1InHZlhh5lQFZ+Pj/mD3qRX9jgH9FW17qGq/25O9vWMYVzfLHO9NT9zSAmg2JLCRoSS1s5j/11k57UV6sR9j/c6AswnH30KTQN83QBHpfJfXwtqHv3O5488Tp2au7lcCPzbxziYQw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558297888865369.65135834481714; Sun, 19 May 2019 13:31:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:53021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSSt-0006U0-NX for importer@patchew.org; Sun, 19 May 2019 16:31:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSI2-0005kB-FB for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSI1-0007gX-77 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:14 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:45335) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSHy-0007Yi-TD for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:12 -0400 Received: by mail-pf1-x441.google.com with SMTP id s11so6138582pfm.12 for ; Sun, 19 May 2019 13:20:10 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IbY6I9DzAmMV/VMKU0boKo5CQjvFhhAqBWPLdeOiiQg=; b=tEbvvc7t1WACcnjP/5ylyqvnQoRBTCzCRHsXBCK4TES4dQkIQcGYyu7qbaF4/F8uDb GEaZCNUUcDsHpV83mTzUaWlektLdYY3Ip8WBvahvVH427Nbxd3Byg6D1EX2eF4JyT8R/ iOFhN48bZQNbT1f5jVc/3J+xeYBfs2ru0h4thwxI5NeYw5o7TWfg/dZoVDJ95kEODmbR Uo5BLpHe2ADscRrU9Pd0kyhO22TNvtTVJNo7yoznF07C7nKr+YQMIFDDP4SGuiI/w156 lhsE6mdaiCkWJCIWoypQHiYx1KNiY39SM68ZLyIbx5jVG0DiH7FORxHOnsUwzf2wO+fw hIRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IbY6I9DzAmMV/VMKU0boKo5CQjvFhhAqBWPLdeOiiQg=; b=lU3xUnquejtW52I7uwPuPiRW5ij2R3RRHPsE9UogYdnFoOym+ZIeJw+4g3LZhiZZb+ HgbvbJ7la6plswzqgb6yH8ozBc873IeEUmbqtu5G3tigXZZ8Fh5uuSAK+FAgaGoLVxFN 1dsgnAStPuLXonIEPvNCYGLpkTT1W8moAAjzkLt4nrLyMn+U1NjwjdpnpUuiqYwURv5j wCDPdvGmwa903+sIiyGn/L/IEMciafg9qUb+fB4B2HLCzphPnXnuZEi1EtmZCUEp0+A0 LTQnievTAnkVi2t7siI/69L6z7EEhVzgns4TDs8nI93g8JpSeMALY2aye4V5ZBxRKMhg wWfQ== X-Gm-Message-State: APjAAAU5N8yZWAOBH/1M8phm9mVwhL37EiSROVfEImXMxleDRxIOukAc CLJ0I3lXfWvJrvd+iHIMrFLD/JBG7sQ= X-Google-Smtp-Source: APXvYqzV4ly4FxYMXhEttULuXS3wtcrIZgVwDR0TWaplV9ItPC3Dqugk8Mg4ftahv3h1Auwy5dHxvQ== X-Received: by 2002:a63:700b:: with SMTP id l11mr15541010pgc.449.1558297209546; Sun, 19 May 2019 13:20:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:51 -0700 Message-Id: <20190519201953.20161-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 11/13] tests/tcg/multiarch/linux-test: Fix error check for shmat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The error indicator for this syscall is -1, not 0. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- tests/tcg/multiarch/linux-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-t= est.c index fa4243fc04..673d7c8a1c 100644 --- a/tests/tcg/multiarch/linux-test.c +++ b/tests/tcg/multiarch/linux-test.c @@ -503,8 +503,9 @@ static void test_shm(void) =20 shmid =3D chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777)); ptr =3D shmat(shmid, NULL, 0); - if (!ptr) + if (ptr =3D=3D (void *)-1) { error("shmat"); + } =20 memset(ptr, 0, SHM_SIZE); =20 --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558298308; cv=none; d=zoho.com; s=zohoarc; b=CprVVXGxqj0iLTEo6wYJZPjZGzKXd/RmjRnGTIryV/hAzKeKUEzLPBoTY3CqaYBwBo44lLceHkw4ypaBtEqsiP0uKyZUxGU5PlbGV4lGC18aCbtNUAueDWDPcz5FNUVwrIVwjMvmHy43K48X7XvNZbYTUhZRNLs84uQh0TE0cpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558298308; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SiayGyQLvWgiqh6AWRkbo8bNn33tFxS579n6WOmgYIY=; b=PSIILwD+8OUv4u6qBWCmQIfLK7jVHXYKkbKx636lG+fr/F8yFBNfe6Dey3DMfjNZNxRDcptlIBn//oA49QM0HXOn+vbS+0T+qx7sUVlIeI2YtGn6Sk0ZvbBih+lNz5CmsZmFzCJne4C64FldWFozqUzzV9VmIT9BVF7v9DldAOI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558298308799352.788580631281; Sun, 19 May 2019 13:38:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:53110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZb-0002mi-VX for importer@patchew.org; Sun, 19 May 2019 16:38:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSI4-0005kw-B5 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSI1-0007gi-8h for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:15 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:35512) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSI0-0007cy-Ja for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:12 -0400 Received: by mail-pl1-x641.google.com with SMTP id p1so326972plo.2 for ; Sun, 19 May 2019 13:20:12 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SiayGyQLvWgiqh6AWRkbo8bNn33tFxS579n6WOmgYIY=; b=td151MifHmQglT9fSzTLa8/xgbDoW+f2CiheDLqtm9TYH26L9MS10aENkZgFKAbqZo mscpsRTUl0xC01PjpO27A6c5QINPldHpWyFDfIht5UroqWPo8oO7UYuGfWz8Ne8WyFeB nND5iTozv5hEKt8CwdWLjtVMTskRf2BauHmFcRRPWBjbhN7VRbPkVimcJHs0hyPdPY95 YUQSkgwAFSpGWyyz0zyR+JUIkNv+vEcwm5ngLcg0KmPFOOpc1G/rXtfBj0MU0kUiZv0E NIYYsG03r0kfyBys8DPxTm9tiA1DVe0nFuyq8bFGAT41De2D81UBWBqgJPbzGTzMT3W5 /a5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SiayGyQLvWgiqh6AWRkbo8bNn33tFxS579n6WOmgYIY=; b=CPwVnnYByFW6CC3Z+6Hf4X8FKTEYWvJpFKv4SNQf4LHep79Ccuj3d6eaXoHaF9bCO3 wqMmNuB5D3/JL/1T//lU+AFKXTYa2A+zkjxbh9c5RLOZSEeO7SCPgyxsoj5qvuGOX3AR xse12Kz9P7ldl6WJWT1AD7PpweYf4yS5G+u+7H0ms2x8Y/kkc8tvP6ap/nfkkO9pXeQT 8Epxgd7G6tExtPQbEHenrwsOw3FyDbe469dmHCOtSd1GKRveLy5Tq3eOVzBtAHvwsL3K cWSJX4p1ppRIv5cM6swPlVRg9SUZYTYpccVvFeFe3JEQNicvO6xfrcC0LiG1d/9tLI2v rHsw== X-Gm-Message-State: APjAAAVRhqkgl8PgZy1PHNi+EHQUuHxdg6Mhkcuybg9/AJTem89POZ7K pI+Tsg/yLMpuVAyIpuG81BdsXgHqKTA= X-Google-Smtp-Source: APXvYqwooEaDDqayizDKzYPqI2W8uD8zX85YcLlXErZmgBpvQJjxqtoj2mMtigO7LBwlcehMzfTFhg== X-Received: by 2002:a17:902:1126:: with SMTP id d35mr36073717pla.82.1558297210992; Sun, 19 May 2019 13:20:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:52 -0700 Message-Id: <20190519201953.20161-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH 12/13] linux-user: Fix shmat emulation by honoring host SHMLBA X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For those hosts with SHMLBA > getpagesize, we don't automatically select a guest address that is compatible with the host. We can achieve this by boosting the alignment of guest_base and by adding an extra alignment argument to mmap_find_vma. Signed-off-by: Richard Henderson --- linux-user/qemu.h | 2 +- linux-user/elfload.c | 17 +++++----- linux-user/mmap.c | 74 +++++++++++++++++++++++--------------------- linux-user/syscall.c | 3 +- 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ef400cb78a..82d33d7e93 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -443,7 +443,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong ol= d_size, abi_ulong new_addr); extern unsigned long last_brk; extern abi_ulong mmap_next_start; -abi_ulong mmap_find_vma(abi_ulong, abi_ulong); +abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong); void mmap_fork_start(void); void mmap_fork_end(int child); =20 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index ef42e02d82..fe9f07843e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3,6 +3,7 @@ #include =20 #include +#include =20 #include "qemu.h" #include "disas/disas.h" @@ -2012,6 +2013,8 @@ unsigned long init_guest_space(unsigned long host_sta= rt, unsigned long guest_start, bool fixed) { + /* In order to use host shmat, we must be able to honor SHMLBA. */ + unsigned long align =3D MAX(SHMLBA, qemu_host_page_size); unsigned long current_start, aligned_start; int flags; =20 @@ -2029,7 +2032,7 @@ unsigned long init_guest_space(unsigned long host_sta= rt, } =20 /* Setup the initial flags and start address. */ - current_start =3D host_start & qemu_host_page_mask; + current_start =3D host_start & -align; flags =3D MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; if (fixed) { flags |=3D MAP_FIXED; @@ -2065,8 +2068,8 @@ unsigned long init_guest_space(unsigned long host_sta= rt, return (unsigned long)-1; } munmap((void *)real_start, host_full_size); - if (real_start & ~qemu_host_page_mask) { - /* The same thing again, but with an extra qemu_host_page_size + if (real_start & (align - 1)) { + /* The same thing again, but with extra * so that we can shift around alignment. */ unsigned long real_size =3D host_full_size + qemu_host_page_si= ze; @@ -2079,7 +2082,7 @@ unsigned long init_guest_space(unsigned long host_sta= rt, return (unsigned long)-1; } munmap((void *)real_start, real_size); - real_start =3D HOST_PAGE_ALIGN(real_start); + real_start =3D ROUND_UP(real_start, align); } current_start =3D real_start; } @@ -2106,7 +2109,7 @@ unsigned long init_guest_space(unsigned long host_sta= rt, } =20 /* Ensure the address is properly aligned. */ - if (real_start & ~qemu_host_page_mask) { + if (real_start & (align - 1)) { /* Ideally, we adjust like * * pages: [ ][ ][ ][ ][ ] @@ -2134,7 +2137,7 @@ unsigned long init_guest_space(unsigned long host_sta= rt, if (real_start =3D=3D (unsigned long)-1) { return (unsigned long)-1; } - aligned_start =3D HOST_PAGE_ALIGN(real_start); + aligned_start =3D ROUND_UP(real_start, align); } else { aligned_start =3D real_start; } @@ -2171,7 +2174,7 @@ unsigned long init_guest_space(unsigned long host_sta= rt, * because of trouble with ARM commpage setup. */ munmap((void *)real_start, real_size); - current_start +=3D qemu_host_page_size; + current_start +=3D align; if (host_start =3D=3D current_start) { /* Theoretically possible if host doesn't have any suitably * aligned areas. Normally the first mmap will fail. diff --git a/linux-user/mmap.c b/linux-user/mmap.c index e0249efe4f..10796b37ac 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -202,49 +202,52 @@ unsigned long last_brk; =20 /* Subroutine of mmap_find_vma, used when we have pre-allocated a chunk of guest address space. */ -static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size) +static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size, + abi_ulong align) { - abi_ulong addr; - abi_ulong end_addr; + abi_ulong addr, end_addr, incr =3D qemu_host_page_size; int prot; - int looped =3D 0; + bool looped =3D false; =20 if (size > reserved_va) { return (abi_ulong)-1; } =20 - size =3D HOST_PAGE_ALIGN(size); - end_addr =3D start + size; - if (end_addr > reserved_va) { - end_addr =3D reserved_va; - } - addr =3D end_addr - qemu_host_page_size; + /* Note that start and size have already been aligned by mmap_find_vma= . */ =20 + end_addr =3D start + size; + if (start > reserved_va - size) { + /* Start at the top of the address space. */ + end_addr =3D ((reserved_va - size) & -align) + size; + looped =3D true; + } + + /* Search downward from END_ADDR, checking to see if a page is in use.= */ + addr =3D end_addr; while (1) { + addr -=3D incr; if (addr > end_addr) { if (looped) { + /* Failure. The entire address space has been searched. = */ return (abi_ulong)-1; } - end_addr =3D reserved_va; - addr =3D end_addr - qemu_host_page_size; - looped =3D 1; - continue; + /* Re-start at the top of the address space. */ + addr =3D end_addr =3D ((reserved_va - size) & -align) + size; + looped =3D true; + } else { + prot =3D page_get_flags(addr); + if (prot) { + /* Page in use. Restart below this page. */ + addr =3D end_addr =3D ((addr - size) & -align) + size; + } else if (addr && addr + size =3D=3D end_addr) { + /* Success! All pages between ADDR and END_ADDR are free.= */ + if (start =3D=3D mmap_next_start) { + mmap_next_start =3D addr; + } + return addr; + } } - prot =3D page_get_flags(addr); - if (prot) { - end_addr =3D addr; - } - if (addr && addr + size =3D=3D end_addr) { - break; - } - addr -=3D qemu_host_page_size; } - - if (start =3D=3D mmap_next_start) { - mmap_next_start =3D addr; - } - - return addr; } =20 /* @@ -253,7 +256,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start= , abi_ulong size) * It must be called with mmap_lock() held. * Return -1 if error. */ -abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) +abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { void *ptr, *prev; abi_ulong addr; @@ -265,11 +268,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong si= ze) } else { start &=3D qemu_host_page_mask; } + start =3D ROUND_UP(start, align); =20 size =3D HOST_PAGE_ALIGN(size); =20 if (reserved_va) { - return mmap_find_vma_reserved(start, size); + return mmap_find_vma_reserved(start, size, align); } =20 addr =3D start; @@ -299,7 +303,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) if (h2g_valid(ptr + size - 1)) { addr =3D h2g(ptr); =20 - if ((addr & ~TARGET_PAGE_MASK) =3D=3D 0) { + if ((addr & (align - 1)) =3D=3D 0) { /* Success. */ if (start =3D=3D mmap_next_start && addr >=3D TASK_UNMAPPE= D_BASE) { mmap_next_start =3D addr + size; @@ -313,12 +317,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong si= ze) /* Assume the result that the kernel gave us is the first with enough free space, so start again at the next higher target page. */ - addr =3D TARGET_PAGE_ALIGN(addr); + addr =3D ROUND_UP(addr, align); break; case 1: /* Sometimes the kernel decides to perform the allocation at the top end of memory instead. */ - addr &=3D TARGET_PAGE_MASK; + addr &=3D -align; break; case 2: /* Start over at low memory. */ @@ -416,7 +420,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, if (!(flags & MAP_FIXED)) { host_len =3D len + offset - host_offset; host_len =3D HOST_PAGE_ALIGN(host_len); - start =3D mmap_find_vma(real_start, host_len); + start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; goto fail; @@ -710,7 +714,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong ol= d_size, } else if (flags & MREMAP_MAYMOVE) { abi_ulong mmap_start; =20 - mmap_start =3D mmap_find_vma(0, new_size); + mmap_start =3D mmap_find_vma(0, new_size, TARGET_PAGE_SIZE); =20 if (mmap_start =3D=3D -1) { errno =3D ENOMEM; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f960556bf8..1feb740f66 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3912,7 +3912,8 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_en= v, else { abi_ulong mmap_start; =20 - mmap_start =3D mmap_find_vma(0, shm_info.shm_segsz); + /* In order to use the host shmat, we need to honor host SHMLBA. = */ + mmap_start =3D mmap_find_vma(0, shm_info.shm_segsz, MAX(SHMLBA, sh= mlba)); =20 if (mmap_start =3D=3D -1) { errno =3D ENOMEM; --=20 2.17.1 From nobody Mon Feb 9 09:03:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1558298056; cv=none; d=zoho.com; s=zohoarc; b=UW3vd2+zwG5f9ATwx5i1GfpJSDGSQtBGhfmYF/tom/LH7xkA5jz6E9U1tKN+n2CG/Vj96XUpse73+0CmiGiaOkadc214g8Cd4Fdem075HnuYYn6pAjCtC/gST6GD8mekB8Kg1DCoZXj8jgH5yPIPvd4YawAsHsMBfJSlsjiNjso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558298056; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vXq6cXFo3n3RVYR19bI6vVgQuVdOYZC397oTA+hZL94=; b=FbbRLUJa7aOcsdxl++v4kcQKD4lKSlGuseBeX2T+agAv1XsXR/cX67/L+VnbEAHvgX3dLXtjMvlxPpbR7Xs2dAz802dtXDqH0mzc3s65QvL6A91svSbqpQ+Mx5NwL2wqlHb1BL8aUEeNKS2RgdHvO4i9ptFkekje+x/tdpVAAQI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558298056178339.5528288672539; Sun, 19 May 2019 13:34:16 -0700 (PDT) Received: from localhost ([127.0.0.1]:53039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSVS-0008GW-2n for importer@patchew.org; Sun, 19 May 2019 16:34:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSI8-0005qE-U0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSI4-0007mU-AQ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:19 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:42850) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSI2-0007hi-Fm for qemu-devel@nongnu.org; Sun, 19 May 2019 16:20:14 -0400 Received: by mail-pf1-x441.google.com with SMTP id 13so6147608pfw.9 for ; Sun, 19 May 2019 13:20:14 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id e14sm18166264pff.60.2019.05.19.13.20.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vXq6cXFo3n3RVYR19bI6vVgQuVdOYZC397oTA+hZL94=; b=h/5t8SuJPF66yPg5KIK/1+q6l/zoXStcVF83BnUmASs+IJyugUpLxXyx5pkEHO2hpM H60lx4VC1JmsMfBFxLoFBP/dDHmB4KUBE1wAm2POAJVNHffSISkK3n1K1/PW6X9dgoSt oi42aOs3OfIIss0p1G0wVS2nKOrqanShKyLZ88xgPkyo8JQji5K5/SWyW0OWBDF4MfSP 52VOditXiH+azKus5npX8TUrWWLx9+/RZGT489fFhCzdhXVjTBb0gyQpfbXS83HotV3w TEL56sGRpuijYhDzz3evCXg1VSkd8WbNutAO/vNp8ED01h9N2n9mUyJa3PRMkvpnk6QD x3ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vXq6cXFo3n3RVYR19bI6vVgQuVdOYZC397oTA+hZL94=; b=YHtAbUFEITZskA8tWuXYnQY8Blc+18qzGHDIxDMILaZ/HBl/Y9K8yYGIcm+3QpK2J+ gSNs2rigz/0ktmGlJoX8HJsE5YwaK2Qc9lkHSLJ0utwuVF5w8R75Xvu3DxzvwQbdlIlZ /bk1pE+0qzl/s8X9a1Z+xz77G1UyvLLJj3MZC8hupFesMpSaXVS0Boj1vx4qR8Mojst+ TOsjQ/u4tMmNCxHCPB+U+8bzmrMtJS9oXERsrz2yQ+x09fgaJhHBqAoKYzye/n2ZS6KA myQUta9EBE2io8XcZhfOuM7ZvjqIwLGa0sL5/xSuSC56ozbLholmrTd5uoGTxSUKtiWi QMlA== X-Gm-Message-State: APjAAAUKjStjMbwXxyHTjVT13q2QkwPVKOegQ9ev1p/D7+K3x3p4Nddo f2jKKz7koYghwIMWp2zKNZy8zghcDRI= X-Google-Smtp-Source: APXvYqyW5CgWr5ssPcFw3NOv4uJ2N2G1k/twgBwCXJ6CUimg/ZXCE5WFTkmnx/+XUQZsJYQ9VLB7GA== X-Received: by 2002:a63:1e4d:: with SMTP id p13mr71552853pgm.125.1558297212217; Sun, 19 May 2019 13:20:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:19:53 -0700 Message-Id: <20190519201953.20161-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519201953.20161-1-richard.henderson@linaro.org> References: <20190519201953.20161-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 13/13] linux-user: Align mmap_find_vma to host page size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This can avoid stack allocation failures for i386 guest on ppc64 (64k page) host. Suggested-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/mmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 10796b37ac..af41339d57 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -262,6 +262,8 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) abi_ulong addr; int wrapped, repeat; =20 + align =3D MAX(align, qemu_host_page_size); + /* If 'start' =3D=3D 0, then a default start address is used. */ if (start =3D=3D 0) { start =3D mmap_next_start; --=20 2.17.1