From patchwork Sun May 19 20:19:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164479 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4768647ili; Sun, 19 May 2019 13:23:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzafgckhGEFrJB+XTQJMbWkGBEYyXkOoFlBRXWbCN/XbBgfqmZwDfqTq8mBxoOPZ4/OjBbZ X-Received: by 2002:a50:9785:: with SMTP id e5mr70707296edb.94.1558297380658; Sun, 19 May 2019 13:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297380; cv=none; d=google.com; s=arc-20160816; b=pIm3cXPTvCgXw154rth9GNcD3Yb5IyW25wthlptENwXWINS2th5TF22b7dkUD663UE Z00rhTrrXlazALcZrHYlsbAuANX0zb0u1u1pxb4FvMlqIjppR98SPxkHe3DEn5Vxw9Oj 2+C3SS4EGK8WLDuYy9D/djgtddGcXSgBYQW6Ce5ZMgMXWpyrrTesC+zpAf4im+6PW5Nr UCsIFpfmwizpsscSLZaUA3b2tYl3xEZRXX6VSP1orHwwQftYQ5kUX1sx9zCmMgbJsFYF Px4rT1a6dTmWz6m4suwWFuv/rcEVCA0Xrzizxh0XUp0MOi1uCMs9M37t8YpHn3CdaYAW MrDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=F6v6DXx3p/jSQwESHeV1J+7APHSrqQWGEt14uQc8gHo=; b=Sg9dOluYZNIkG+DTvwSoOLgmBynr9NEQ/o58vtsuFZHSswHyhpz1lGrwBjaeSs9AmE L/Y/72Ormcp4JhqWsD4Drq6d2N48naEVlqIQtBpgPJYGxLIjlKD3g/MDWP2u3Qne/m4o ESd+2WPo7tQFfb6EG2kVkq2TN0VimA99m3JSvvSvEyprgjhjiPn3iftfTcd6lq7ulc0D gogtw4sID08f7eYuSoAaq7qjReJix3QYNtbEJ1RbLqF5jgoVhdx366jTHDqSo9KU098A 6oTqvJKXtHR0Ww2ep/KBZD8I0RBmYlF7YQKZJlf7VlTnaG26U5mbM1cf+HECoJFXgEn3 ApNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LNoyolei; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dv25si279722ejb.383.2019.05.19.13.23.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:23:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LNoyolei; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSKh-0008Ba-FE for patch@linaro.org; Sun, 19 May 2019 16:22:59 -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) 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-Received: by 2002:a63:144e:: with SMTP id 14mr53861332pgu.304.1558297197610; Sun, 19 May 2019 13:19:57 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- util/path.c | 201 ++++++++++++---------------------------------------- 1 file changed, 47 insertions(+), 154 deletions(-) -- 2.17.1 Reviewed-by: Laurent Vivier Tested-by: Laurent Vivier 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" -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 = 0; i < n; i++) - if (s1[i] != s2[i]) - return 0; - return s2[i] == 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 = g_malloc(sizeof(*new)); - new->name = g_strdup(name); - new->pathname = g_strdup_printf("%s/%s", root, name); - new->num_entries = 0; - return new; -} - -#define streq(a,b) (strcmp((a), (b)) == 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) == DT_DIR || (type) == DT_UNKNOWN || (type) == 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 = opendir(path->pathname)) != NULL) { - struct dirent *dirent; - - while ((dirent = readdir(dir)) != NULL) { - if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){ - path = add_entry(path, dirent->d_name, dirent_type(dirent)); - } - } - closedir(dir); - } - return path; -} - -static struct pathelem *add_entry(struct pathelem *root, const char *name, - unsigned type) -{ - struct pathelem **e; - - root->num_entries++; - - root = g_realloc(root, sizeof(*root) - + sizeof(root->entries[0])*root->num_entries); - e = &root->entries[root->num_entries-1]; - - *e = new_entry(root->pathname, root, name); - if (is_dir_maybe(type)) { - *e = 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 = parent; - for (i = 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 += strspn(name, "/"); - namelen = strcspn(name, "/"); - - if (namelen == 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 = 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; void init_paths(const char *prefix) { - char pref_buf[PATH_MAX]; - - if (prefix[0] == '\0' || - !strcmp(prefix, "/")) + if (prefix[0] == '\0' || !strcmp(prefix, "/")) { return; - - if (prefix[0] != '/') { - char *cwd = getcwd(NULL, 0); - size_t pref_buf_len = 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 = new_entry("", NULL, pref_buf); - base = add_dir_maybe(base); - if (base->num_entries == 0) { - g_free(base->pathname); - g_free(base->name); - g_free(base); - base = NULL; - } else { - set_parents(base, base); } + + if (prefix[0] == '/') { + base = g_strdup(prefix); + } else { + char *cwd = g_get_current_dir(); + base = g_build_filename(cwd, prefix, NULL); + g_free(cwd); + } + + hash = g_hash_table_new(g_str_hash, g_str_equal); + qemu_mutex_init(&lock); } /* 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] != '/') - return name; + gpointer key, value; + const char *ret; - return follow_path(base, name) ?: name; + /* Only do absolute paths: quick and dirty, but should mostly be OK. */ + if (!base || !name || name[0] != '/') { + return name; + } + + qemu_mutex_lock(&lock); + + /* Have we looked up this file before? */ + if (g_hash_table_lookup_extended(hash, name, &key, &value)) { + ret = value ? value : name; + } else { + char *save = g_strdup(name); + char *full = g_build_filename(base, name, NULL); + + /* Look for the path; record the result, pass or fail. */ + if (access(full, F_OK) == 0) { + /* Exists. */ + g_hash_table_insert(hash, save, full); + ret = full; + } else { + /* Does not exist. */ + g_free(full); + g_hash_table_insert(hash, save, NULL); + ret = name; + } + } + + qemu_mutex_unlock(&lock); + return ret; } From patchwork Sun May 19 20:19:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164480 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4770448ili; Sun, 19 May 2019 13:25:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsz9KYsh/OOtl4WQDEIjeI4RyDYTldP/KFwg1Q8sRh9LrcSHVMg5qyYZ+rWvPd2xpoIT/v X-Received: by 2002:a50:8e1e:: with SMTP id 30mr71765512edw.283.1558297552733; Sun, 19 May 2019 13:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297552; cv=none; d=google.com; s=arc-20160816; b=Pwfo6PjMLxz0YFetw/sTxHWpSWPYvWum9urxKDL67/hJ6ozwd7YzzL9CuiaRuCBt/H P5vi7Yozx9AWTaXqkdTx9yhOH0TsCfFnFYqVnqN8mKznG5tQYuObexzQFVP6f5VeH7At 4Fn52H8ti4t/eoHT2LD/0PeX1bon5g86MVMpuQ/qRO6fZZEKNBpedp7Wqjclp5Nd882k stP9+pdP1thtQ8CS7pjWpo4cZ4+OTtea9bkyogsQxR9K7IfB0ZFA9WihPJYS0pSjv0OR Md+7hNmJ0n66dEazii5bTFeoYVTIs/R7ZlECqI5VN0N1Z80enmKAhI9W9+TCMQEanE9K LpVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=rXfSo9Gy+xV7gUMCOu/4nLM098jgkgLPcgtIQzZJ9xs=; b=Sk+GsftjFlgeCYFSOkczJ1cR+aDR3mROCD4HGg/6VIIqs2dMc8IAeT77kTd5zhVbP6 3KJT/kmzxJBkD7EEtAUu8XCgp4hoatLA6CrZLkDGBUAjuh9R0w94OpDpVWx+56uIB/lC geQGJiIZpxjr4JEt0Oqt9E5kQgg67Si3kSzvc7PBsKJYY7Fo4skpzY3LVBQ42njQftqg h/Vz9V8wY6HCdUeZjlLQqwG0idWBwoZaowuhkbeZf+Erc8t+sjVhn93zyjvOj71NPp64 y9AZA4XAhLoq/jOp2o4IVlyStRh55kzTLg3sxndsVCPc/ohCRkdQKEvckPGpwnDYSrQg T9lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JTjGItOn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id by19si9432135ejb.20.2019.05.19.13.25.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JTjGItOn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSNT-00029G-Fd for patch@linaro.org; Sun, 19 May 2019 16:25:51 -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) 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-Received: by 2002:a65:60d2:: with SMTP id r18mr24719608pgv.217.1558297198793; 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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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(-) -- 2.17.1 Reviewed-by: Laurent Vivier diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.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 -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp) { if (newsp) { env->xregs[31] = 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 -static inline void cpu_clone_regs(CPUAlphaState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUAlphaState *env, target_ulong newsp) { if (newsp) { env->ir[IR_SP] = 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 -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp) { if (newsp) { env->regs[13] = 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 -static inline void cpu_clone_regs(CPUCRISState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUCRISState *env, target_ulong newsp) { if (newsp) { env->regs[14] = 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 -static inline void cpu_clone_regs(CPUHPPAState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUHPPAState *env, target_ulong newsp) { if (newsp) { env->gr[30] = 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 -static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUX86State *env, target_ulong newsp) { if (newsp) { env->regs[R_ESP] = 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 -static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUM68KState *env, target_ulong newsp) { if (newsp) { env->aregs[7] = newsp; diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_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 -static inline void cpu_clone_regs(CPUMBState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMBState *env, target_ulong newsp) { if (newsp) { env->regs[R_SP] = 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 -static inline void cpu_clone_regs(CPUMIPSState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMIPSState *env, target_ulong newsp) { if (newsp) { env->active_tc.gpr[29] = 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 -static inline void cpu_clone_regs(CPUNios2State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUNios2State *env, target_ulong newsp) { if (newsp) { env->regs[R_SP] = 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 -static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) +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 -static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUPPCState *env, target_ulong newsp) { if (newsp) { env->gpr[1] = 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 -static inline void cpu_clone_regs(CPURISCVState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPURISCVState *env, target_ulong newsp) { if (newsp) { env->gpr[xSP] = 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 -static inline void cpu_clone_regs(CPUS390XState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUS390XState *env, target_ulong newsp) { if (newsp) { env->regs[15] = 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 -static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSH4State *env, target_ulong newsp) { if (newsp) { env->gregs[15] = 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 -static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp) { if (newsp) { env->regwptr[22] = 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 -static inline void cpu_clone_regs(CPUTLGState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUTLGState *env, target_ulong newsp) { if (newsp) { env->regs[TILEGX_R_SP] = 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 -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] = 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 flags, abi_ulong newsp, /* we create a new CPU instance. */ new_env = 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 = ENV_GET_CPU(new_env); new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; @@ -5612,7 +5612,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, ret = fork(); if (ret == 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 From patchwork Sun May 19 20:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164482 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4771156ili; Sun, 19 May 2019 13:27:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyCxp3ABljz05Wdhv737BG5LFI8DfYhtvT6vTkV3fbP9B/xCD0EuOWdgGLw0ag/64V0wV3 X-Received: by 2002:a17:906:7047:: with SMTP id r7mr12169636ejj.11.1558297634948; Sun, 19 May 2019 13:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297634; cv=none; d=google.com; s=arc-20160816; b=rN6xP1ZR7aYPv17XjWh+NqneQIVSdbz8mv6l9d1jXwdn44zuprrrKP4dB+Jvy/gjmH oBCXa/hOm2PMiCA7y7XS97eTIOzXmTcTl9NG73RXwqAgLrZejAtJxH2tZFmnAwaPV9qV ID5aE1xUkmibhhJfSWyu7DDtTFn016S3xf3K+tG/xplMAkyFkWYLr4fAn8vOrK8ide3c WuFsjxypwTdigdEubRl1tg3DXnVMtsz8AfgeboJVFYeW4yjXw+ge11Ii0swk9xH0B+fn qCyitW02aRY4HSRt8QpNoflCDm0Nk9frOvz1Ws2oCCqZZIJAHCiQsnu5pgSl6HnOPngt d7CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zw4bkjQURlIrIACI3Vx6Yhusz3QTf2Vu+wCw/S+ioOk=; b=bY9e6ajEADsUzh7CPEVoDhVljgjQlD7nhami95Ox+PyT7qFILsUDj8x1dv20nE8B/d +K32x8GatoH53sNUAZQs/OH7oVtPOETOe91MQtIsFqHPryzSoR8/rrAjwKNwQhlBn+ht SvxOVOsS8rQX8Hzo2NRr39EGeylI1TcsO5bBt9F8UJrcUBIudz4NrneeDamyRA5Nd8hs Fl1T1ww0JoBJmbvo98Y4IdjYSMZ/8ejFS8A3Zv/hjFcLS7boAbUm8+qV7Lwqhhzr4cvc 83WxLczsMUX+dF+S/04rOrW+xPAvm66SOQjs8kw7Trc1MwzAdiQgUp8H/KrElxOIvt8H Mevg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ZPIP/XBV"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l55si763737edd.288.2019.05.19.13.27.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ZPIP/XBV"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSOn-0003YY-NF for patch@linaro.org; Sun, 19 May 2019 16:27:13 -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) 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-Received: by 2002:a63:7413:: with SMTP id p19mr69066270pgc.259.1558297200058; 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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:19:59 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add an empty inline function for each target, and invoke it from the proper places. Signed-off-by: Richard Henderson --- 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(+) -- 2.17.1 Reviewed-by: Laurent Vivier diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.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] = 0; } +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 *env, target_ulong newsp) env->ir[IR_A3] = 0; } +static inline void cpu_clone_regs_parent(CPUAlphaState *env) +{ +} + static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls) { env->unique = 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] = 0; } +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 *env, target_ulong newsp) env->regs[10] = 0; } +static inline void cpu_clone_regs_parent(CPUCRISState *env) +{ +} + static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls) { env->pregs[PR_PID] = (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 *env, target_ulong newsp) env->iaoq_b = env->gr[31] + 4; } +static inline void cpu_clone_regs_parent(CPUHPPAState *env) +{ +} + static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls) { env->cr[27] = 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] = 0; } +static inline void cpu_clone_regs_parent(CPUX86State *env) +{ +} + #if defined(TARGET_ABI32) abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr); 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 *env, target_ulong newsp) env->dregs[0] = 0; } +static inline void cpu_clone_regs_parent(CPUM68KState *env) +{ +} + static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) { CPUState *cs = CPU(m68k_env_get_cpu(env)); diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_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] = 0; } +static inline void cpu_clone_regs_parent(CPUMBState *env) +{ +} + static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls) { env->regs[21] = 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 *env, target_ulong newsp) env->active_tc.gpr[2] = 0; } +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 = 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 *env, target_ulong newsp) env->regs[R_RET0] = 0; } +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); } +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] = 0; } +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 *env, target_ulong newsp) env->gpr[xA0] = 0; } +static inline void cpu_clone_regs_parent(CPURISCVState *env) +{ +} + static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls) { env->gpr[xTP] = 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 *env, target_ulong newsp) env->regs[2] = 0; } +static inline void cpu_clone_regs_parent(CPUS390XState *env) +{ +} + static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls) { env->aregs[0] = 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] = 0; } +static inline void cpu_clone_regs_parent(CPUSH4State *env) +{ +} + static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls) { env->gbr = 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 *env, target_ulong newsp) #endif } +static inline void cpu_clone_regs_parent(CPUSPARCState *env) +{ +} + static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) { env->gregs[7] = 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] = 0; } +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] = 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] = 0; } +static inline void cpu_clone_regs_parent(CPUXtensaState *env) +{ +} + static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls) { env->uregs[THREADPTR] = 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 flags, abi_ulong newsp, new_env = cpu_copy(env); /* Init regs that differ from the parent. */ cpu_clone_regs_child(new_env, newsp); + cpu_clone_regs_parent(env); new_cpu = ENV_GET_CPU(new_env); new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; @@ -5630,6 +5631,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, if (flags & CLONE_CHILD_CLEARTID) ts->child_tidptr = child_tidptr; } else { + cpu_clone_regs_parent(env); fork_end(0); } } From patchwork Sun May 19 20:19:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164477 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4767637ili; Sun, 19 May 2019 13:21:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWF1Sfl25ytOF8DqY8jPp213ykhTObTwUaryApD9husnZQH07ZQQdtp7lYLCmW8dIDb4sm X-Received: by 2002:a50:fd0a:: with SMTP id i10mr70758214eds.117.1558297273781; Sun, 19 May 2019 13:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297273; cv=none; d=google.com; s=arc-20160816; b=bH/16+AJkK2w45A8soOrH81hwyiUkqdQwmD1jpYGHLEaVKhZ56+kjwGif/iEFOo+fD MjRNjI8JTrq0fDM4bOnXagq1yPVj+3WL+P4ShhIVmDP2PJhSRmgMHTWrG90BRPjgWCTQ Q9/++28X2Nv7gxfWTOTDQjYTuTUKM7QBHwCwdxh9OfBGSTEHQ2teOEpRWWtRMJ4h6nGS +0jE4wpPsegDyBSohHvsBtop+zVRSRn7IGqkT1if805Rk/hvRaGrolvti4EXNDMCK4zS UEQjw2PYLDBQ9xXIyXInpflOdXpSpxuSoy2yk/avucYOFekO4mQmmXojTt+jyEmS8OjI evzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=T2aejSpup/jdLylt16k4iHZTGZjrzCHoXu3LKyQVTCY=; b=a4MF3bbsUhKqM9GUWJPpCK5ENLVHWigwIMUwl/mqmbcKOePOjBb7voKKk3ToTFHcwq gn071my3VG7HDVm+xAKQ3D3ClsNLiYp2kTMswdO5eM5PvfRJllDLmw3GbWUMKYzxAbJm KXj9ZWGuTZxQssGQGKqs1C1doiFwJw39YBg4NFgRere1KrS9ZKfBAywsIc7pcMg6tsa/ kuRvK0df/F29nJdW2PSNwlLqTwfrSlZTLSLTp8pLAzjmq1CpNPnEVQ2JBzSZGsFyZECO KW+iFMTqtEsV6mqfcycKg8Ecysz+e4AaqwFqok01autoXYcVXFsZ+z78x2p6k1x+gWfU pcWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KjKTKbRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x20si4681450edm.69.2019.05.19.13.21.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KjKTKbRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSIy-0006AI-Jc for patch@linaro.org; Sun, 19 May 2019 16:21:12 -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) 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-Received: by 2002:a63:1d02:: with SMTP id d2mr71711540pgd.26.1558297201454; 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.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:00 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.17.1 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] = 0; env->ir[IR_A3] = 0; + env->ir[IR_A4] = 1; /* OSF/1 secondary return: child */ } static inline void cpu_clone_regs_parent(CPUAlphaState *env) { + env->ir[IR_A4] = 0; /* OSF/1 secondary return: parent */ } static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls) From patchwork Sun May 19 20:19:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164484 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4772635ili; Sun, 19 May 2019 13:29:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWaJvJVduQGBqWeraMlU9DFCkCKqw5Y9lBNjjfdBVabvVWO/HsgDf3H5uKk7pT6xZXD+uR X-Received: by 2002:a50:f4cb:: with SMTP id v11mr72514709edm.21.1558297771801; Sun, 19 May 2019 13:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297771; cv=none; d=google.com; s=arc-20160816; b=xUFZVSi5D/ec54BmoUKDgSH8SjNoYUHHKV5l/KZH5dGVBTokNQM1Mt7v2+0SfHsIcx cRtO6PtEVD5r3cMTpsjKIJBPB6WrDssLUnjkn4qFpB65VarXs/HjjbymIYcpspkU9kZd qdpz2BxdkrbyDmhX3mfuVcCkkZrAjbofXA7CdghYuT0PtAUFpvUFibYYTOZPqDMONT/W YTPiuoEsb4EI3nA0sHy0IZrBUbVe96QbgoyStFOkch04V9SUhKqQAyZssM46r3qQZ/dN 3CQXLXAFjhbi5vV2NyNvJkKW0szvrJzb1VPPK5xzMLtlxsEUYJqLbTBGFD7bsew+MtoF +cEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=YyTYkMwm92ztd6dS65T9tL/otWEXmt+Z9GOHdiUg3L0=; b=S4l3LlAj9QbdZ8S5OLGZtZH3JooqqWp5v80uxL/8t9NJie8tnyNkoYQ/fH5p8KKyP1 ChqKGQQI8a4JV/KEHDAEs6czxOjb35YRgRuzyoMf3fv5yQDhTYsJPINc2EtZBTlOTQKc L/cC0Tjaq/24GZgMD2Hf5hZohSyvTvPKcPFiZEXvHYwnebGVova+WDkgLayCk8Uk/QhW Nr5eNslbVjL8v0XdYlCYH/xcungLAmlG1ymcS9TwyWPwppZ2msaCn3ZskwIQM6OJ6UxZ NdMWHaZ2ixEcYwnL/f7exDnaodge8UhDHqoDp7BzNXEZhfdxmkqg678z/Eq5DRAh5BZe i+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dEbW89JO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e2si1795995ejs.209.2019.05.19.13.29.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:29:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dEbW89JO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSR0-0005G7-NK for patch@linaro.org; Sun, 19 May 2019 16:29:30 -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) 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-Received: by 2002:a17:902:8214:: with SMTP id x20mr49272305pln.308.1558297202809; 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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:01 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/sparc/cpu.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 2.17.1 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 @@ /*#define EXCP_INTERRUPT 0x100*/ +/* 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 = WREG_O6, + WREG_FP = WREG_I6, +}; + /* trap definitions */ #ifndef TARGET_SPARC64 #define TT_TFAULT 0x01 From patchwork Sun May 19 20:19:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164481 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4770761ili; Sun, 19 May 2019 13:26:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxe44e5ovPa3jjCcpzILOchXrmuAdrJB/X2bVAIcvyec1bGGe+d1Ge4fEfm075iV1GIqUzn X-Received: by 2002:a17:906:6c94:: with SMTP id s20mr44321454ejr.294.1558297587509; Sun, 19 May 2019 13:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297587; cv=none; d=google.com; s=arc-20160816; b=dOMjXaCNQPQUk23rYxuU5tGCzQaqOui5USllysfIhSoef769GzSOtDuZXXJ5ESdpDX sTRj0gP5YIpdzR6VIjLlFAfEZD8+jdQ5yJfde5B4Df5Iupg0WnLd82yGgv4ALonxSLfJ 7Pf66f/GIhCkTq67khnD/k0v7OZvjwALmrO+wXg26GjZSBfcr39301x3MU1FE2nkIW+f aBUtfGwS+vUlW3BXXxDngGJyTuo5a03PF05uV59MW4NL/lm3dHAWsBKI0PX4uxbpvgPU TLSulLohwoUCeRSwcEwp1X8BGchrRPOlzvF1JIq2LV0Wh1KNE9iY7okkrI3PpYgVBl8u lCpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+/qY9GymWVw9Tgqaah5CkydYCEaLw/iJ0Pj5fe5qwlo=; b=iu9shXI/Y2nUyKCxJMkLa0l+Go2ryaORxpud/qEJzK6id2DC3gpPY96nEVS4UDU9/D wYgrQm9U37SX04G30YHueSyOobJ8h1riDfNB2RVKEqLbVeOW2cAPlLDpfLsEmlW7xiZy cn55+gNj+mKvopHBPEpqLyakxAGWsyiKmMTxjeo4q3gThXIHwdcL1hscqAO/Uu1bFrgX Jhfv2DJj8uEMkJmd2NcVp10DVdBwnEGdEnJZS39wd7He/bPF4ND7l+cPDtrDvLAy/zBp yIfgXMvgWkeN0Im6WDyDKKxhLgsug6rdUmkD3uoitKsMU/B9YjIGV6hc/MrbAZOYfz1s +Avw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a9sy3aEg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r12si548688edm.291.2019.05.19.13.26.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:26:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a9sy3aEg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSO2-0002Tw-Cg for patch@linaro.org; Sun, 19 May 2019 16:26:26 -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) 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-Received: by 2002:a63:d652:: with SMTP id d18mr55026317pgj.112.1558297204034; 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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:03 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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, target_ulong newtls) env->gregs[7] = newtls; } -#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 From patchwork Sun May 19 20:19:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164486 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4774515ili; Sun, 19 May 2019 13:32:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxjAP/xwJjbUVrodAK8fazfxwm8PRHD1jzJcCwKVnz6U+3arUBhDpA4LdolIiM4dZLkpP8 X-Received: by 2002:a50:b3a4:: with SMTP id s33mr71551821edd.112.1558297929338; Sun, 19 May 2019 13:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297929; cv=none; d=google.com; s=arc-20160816; b=jbKHAg16eLzsg+XhQyKJW9ilh37Jiu3MwiD7IUF6l8+MES4XewEo13HIFIN6dxoEK1 gi7qlBfGJgUlihd2qEuh41oiJtMIwfagMV6kuSUGOBa9lzB9rVflHf1ZmBfYYdSKgHdA ASe11lF6PrSty6t69Iuw8b8X9WROKs0rq0C3AO/gp2WshUMQH2lfmwi4p2Xhv5w4ixlz 44+EGz5dovFlcpa9aEnUTQzyVWTw3RVlJXuGRFhqz5FREGrP4KUdn73ZAvcPR6VDydza gebf9ZoniFM4fJtAF+oHz0hxuWlzN8UuEs11UoCqeiaob2Re/SYndbd3q6hQpp93eLML XMTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Ad7p0XpmVmGXkoTgniD57oGcto4g8MS55uU7nmfGDcA=; b=Ro3uFz6BV1HQR3nDXGPlSpDIds+VZOqdf1c4+23CMK/XlTtPLRCXcrY/8LKDe7uUa5 e8rOmm4TmBBCofejS2n6fDlBxtuPq0Myns3AN34XQ+ThLnCghX6MyWj057MiEm9A0vsV dl8G+chy71S9xDMwDh6hXk8Y1xLWCNH+j9KDAX8FWFzZxPOn5hEZl/irz8f5cD+Rf06G ad/sxCs4r8g24P28wiTJxjPfhFOyTFejh0zVXqouB8oLXk9N8+8e0ObSw5OfSs2x9SEr bXyI4oBDF/IFLAqVsVj+BRfXq9tEzq/jtYgf1qfjabRFVpwgMB5K9TL4TaAZS6YV+x4v xV/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="M/84nIqa"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18si1149131ejf.102.2019.05.19.13.32.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="M/84nIqa"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSTY-0007Gc-7W for patch@linaro.org; Sun, 19 May 2019 16:32:08 -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) 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-Received: by 2002:a17:902:8d94:: with SMTP id v20mr2292784plo.99.1558297205244; 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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:04 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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; }; -#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, 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=0; 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; } -#if 0 -static int -setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/ - CPUSPARCState *env, unsigned long mask) -{ - int err = 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))) void setup_frame(int sig, struct target_sigaction *ka, @@ -221,20 +189,20 @@ void setup_frame(int sig, struct target_sigaction *ka, } for (i = 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 = 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; /* 3. signal handler back-trampoline and parameters */ - env->regwptr[UREG_FP] = sf_addr; - env->regwptr[UREG_I0] = sig; - env->regwptr[UREG_I1] = sf_addr + + env->regwptr[WREG_FP] = sf_addr; + env->regwptr[WREG_I0] = sig; + env->regwptr[WREG_I1] = sf_addr + offsetof(struct target_signal_frame, info); - env->regwptr[UREG_I2] = sf_addr + + env->regwptr[WREG_I2] = sf_addr + offsetof(struct target_signal_frame, info); /* 4. signal handler */ @@ -242,11 +210,11 @@ void setup_frame(int sig, struct target_sigaction *ka, env->npc = (env->pc + 4); /* 5. return to kernel instructions */ if (ka->ka_restorer) { - env->regwptr[UREG_I7] = ka->ka_restorer; + env->regwptr[WREG_I7] = ka->ka_restorer; } else { uint32_t val32; - env->regwptr[UREG_I7] = sf_addr + + env->regwptr[WREG_I7] = sf_addr + offsetof(struct target_signal_frame, insns) - 2 * 4; /* mov __NR_sigreturn, %g1 */ @@ -284,7 +252,7 @@ long do_sigreturn(CPUSPARCState *env) sigset_t host_set; int i; - sf_addr = env->regwptr[UREG_FP]; + sf_addr = 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=0; 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]); } /* FIXME: implement FPU save/restore: @@ -433,7 +401,7 @@ void sparc64_set_context(CPUSPARCState *env) abi_ulong fp, i7, w_addr; unsigned int i; - ucp_addr = env->regwptr[UREG_I0]; + ucp_addr = 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; @@ -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])); __get_user(fp, &(ucp->tuc_mcontext.mc_fp)); __get_user(i7, &(ucp->tuc_mcontext.mc_i7)); - w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6]; + w_addr = TARGET_STACK_BIAS + env->regwptr[WREG_FP]; if (put_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), abi_ulong) != 0) { goto do_sigsegv; @@ -534,7 +502,7 @@ void sparc64_get_context(CPUSPARCState *env) target_sigset_t target_set; sigset_t set; - ucp_addr = env->regwptr[UREG_I0]; + ucp_addr = 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])); - w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6]; + w_addr = TARGET_STACK_BIAS + env->regwptr[WREG_FP]; fp = i7 = 0; if (get_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]), abi_ulong) != 0) { From patchwork Sun May 19 20:19:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164483 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4771261ili; Sun, 19 May 2019 13:27:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM3ipcCfqxbag1rXmnhwCGxq3aXCo44IbNLzdaDnQ23s/Jmc2NSyClXXbn4iM+S70kUZVE X-Received: by 2002:a50:919d:: with SMTP id g29mr71076134eda.146.1558297645233; Sun, 19 May 2019 13:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297645; cv=none; d=google.com; s=arc-20160816; b=Ls/6pNDe6/xVnyAI5MCdaEoxyjcRKJRE8xePhn/uX91w3jLfMs09lqg3rTZo7GJ1Hz RKeD0VAXvylf+36/zMeLd5Ub390sgGD9Uyv02YcjsJsxjxIeBArTawNCTOgOhlXDiXPN pXflr6LpOmDEaODY4DpEp4xefhJf9BsPZU2KQyURrHQYxs4qEQn2AZyJM9qzZy6xPlnm KD6GHE1KOT8xGQ7yJicUJ6fMm1uiBvNEMkb9IWESGU8jvNQfCAWkWy0Bzho8nqKT6iaW mqAAPHQVwx5qEDLWCjVqBj+6PafCn3UVHAR/TECqHXY18NZsJ6PuTvQcX2wALTN1qF9X k76w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=POxFIOq98+f7SlQ+Qq4/1i4zdlqYdJgB+ksVYwShoNE=; b=Jk3OUeaYovzw3fEdu3Tg8G3Doy6ahBw1WcXbJmnKv6my6CNLIejyOWsverBcIZaHhI iqp/nvegTWJ52nrXlotwdgb8pLIYgol9jTylVbq8IItilM1U1P2gPVf51zlG+kqHRn+r yH+zzIq512R00+GZd6tUJH8+4WmBBzFDxbsz18/m67vyqIjBFoYkygF3Lz9oP3Pbm50M QL0NwwiX+Lsgm4asmLTnI8Gjv8RJJ8IouCd9nCcF+9a3puVVcMnHCAR3EWgECy5hc5nu qUO372+d9gb7AmPOK6fK1fbOlxgtfVjIjJbjcuXVPfBor9FXP4EeGIPLVmcOa/t5Wxlj xOsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X6fHeKMu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x28si11405696edd.32.2019.05.19.13.27.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:27:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X6fHeKMu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSOy-0003h4-4b for patch@linaro.org; Sun, 19 May 2019 16:27:24 -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) 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-Received: by 2002:a65:5244:: with SMTP id q4mr69698053pgp.79.1558297206298; 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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:05 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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 @@ static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp) { - if (newsp) { - env->regwptr[22] = 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] = 0; + env->regwptr = 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] = newsp; + } + + /* + * Syscall return for clone child: %o0 = 0 and clear CF since + * this counts as a success return value. %o1 = 1 to indicate + * this is the child. Advance the PC past the syscall. + */ + env->regwptr[WREG_O0] = 0; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) env->xcc &= ~PSR_CARRY; #else env->psr &= ~PSR_CARRY; #endif + env->regwptr[WREG_O1] = 1; + env->pc = env->npc; + env->npc = env->npc + 4; } static inline void cpu_clone_regs_parent(CPUSPARCState *env) { + /* Set the second return value for the parent: %o1 = 0. */ + env->regwptr[WREG_O1] = 0; } static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) From patchwork Sun May 19 20:19:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164489 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4777444ili; Sun, 19 May 2019 13:36:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN/6k2jB9OrjepqQZELV7W2ZOHu0pl4OWReNO9b420UdNz+JvQydoSIaOsCImULtYOiOgO X-Received: by 2002:a50:ba6e:: with SMTP id 43mr70392557eds.201.1558298205802; Sun, 19 May 2019 13:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298205; cv=none; d=google.com; s=arc-20160816; b=zC3OYqrAz5WmC2O9mdNw8t+6/Zo4z7m8kA/qT++tFVLSN840XwRN+mxZGc4vSikosR D2TC9BKqbBTpe+e3/YqZxin36a0SW10gY9fN70FD4q/IVrJcYEx1iIhOoyBfaJa3iQBI X7efOv8JprGI8XBVSIBpfZ63DuOLrQBJq/V98aWmb0tylUlKaa630B4po4Nfx15WmmO5 GxiG9x3umdIMPWyLHeF2El9+NOEQ8KG41o9OX6LBQ9GZirCE8S0CWM2yLml3LaM33+4/ LmLUJFXrhY4E7BBWZjMyN6CjXJdph6vnblN8IyYdLtP1lscAdXIeknxgsxp6jlQ7OnFQ V0hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=EslukgOgrXKOg9aqYU0CsDWXr7O+egog9zUh9mSRURk=; b=mecHu0kUfSk4loyBvgW50LjdgQXw564D1UCjRUyQ9GWck2Pihc+Jc/hKToI4CjIAb7 di1BSusN7SvFTvPEz+MyiaCOAuaNG0tRBWJQeJItdjxYmyg6nUBcQJc3nCG+N6mGYeWn JdM/d6a8nug1xAPwAVBkrnPDmlIv7uQgV2I0DeFGzQmnZQyp42TnFEamnsHq472XlnCP nTjc8v8kjrqPbnKFU1jhad/LCYCGJU8qd2hZkShj/1MVWt8vDGapfgmyNBYL/jK3lIEk K3cCB2XQjERsWDUIjZLhskxNRnfGlcuXRHfzq/pZh4WurHxvIjoUDHRZNoqj3flSTkx2 GkXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=spOuULvm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id se27si2886391ejb.2.2019.05.19.13.36.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=spOuULvm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSY0-0002Dn-PL for patch@linaro.org; Sun, 19 May 2019 16:36:44 -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) 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-Received: by 2002:a17:902:8609:: with SMTP id f9mr15303251plo.252.1558297207346; 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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:06 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.17.1 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 = do_syscall (env, env->gregs[1], env->regwptr[0], env->regwptr[1], env->regwptr[2], env->regwptr[3], From patchwork Sun May 19 20:19:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164487 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4774581ili; Sun, 19 May 2019 13:32:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXWPZcInONdGRivxYku/cAbRSVLVYJIFmKZgj7t6DSzUiTBzIVA9SuwKM21/NyJeHWTj/P X-Received: by 2002:a17:906:6a1a:: with SMTP id o26mr14167625ejr.265.1558297934760; Sun, 19 May 2019 13:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297934; cv=none; d=google.com; s=arc-20160816; b=SVEGbErMskf8FlsGAOVWOf+pwPmO7hmJa3KSz8VfEND5McQ5x0ChQPKbmngK90PJAx iPTHtosVb/+VZz/Ur2gBHIleferVxiSnjSw+6Wa+bI5friKbreQ13dkaYqfxpMKnSKrH MT0xN0G/h89mXzNsO/uY9fYOwZsl39+LVv5OnVL9At5GL7P4CSQQd32Ab6satJ2aXCj5 UA0/84ObAhan2AzYjQ1T2efX20Q7ZPZjdz1F7C4tYDrqctmIYW2lRT4FyeZZ5Momc4QI Bb1Zw07Vg2qAdntHnylQajrhAODgdI0pi/WlULik6aKX7jwmcKnYHNMTEm0Zzr21Vhea XWNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=OghAJHs3fOQNasKs983B96RGcVieroO+wnBU19gV5SI=; b=aacdo6pgQx9jDGemEepaVOB1pgorTJLhFp82/V0LpCenyl9D9Ed6KeaIybvMA9A+ta s+yfq/yIrssDNv26NOOvYYveTggHQKxdG82OYXKefAbhLUC11vyMxy3qhYXGfVLPu5oE vnjjq1HKLLL6aLSy1Drb1sUSfOdt2dtfirZYFNDK6AxD3ZrLjYbwN3+8bbeppBhHk6En nEuGLYkvyqnxcgpEZve0JGWQxQ9nSXl8pcVAS33rR3RuycxzNRqktsQ+a+9fpRQVq74u FjGBOQaZxsd1BEP5+SCXGR+MNLXkBncIXejOtBOswphY3X9JWYcodgw9i1K2AkWUTwQW tcYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PgTc8tb0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si1730126ejj.196.2019.05.19.13.32.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:32:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PgTc8tb0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSTd-00074w-Ky for patch@linaro.org; Sun, 19 May 2019 16:32:13 -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) 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-Received: by 2002:a17:902:ac90:: with SMTP id h16mr8998490plr.162.1558297208369; 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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:07 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- scripts/qemu-binfmt-conf.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Laurent Vivier Tested-by: Laurent Vivier 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. -qemu_target_list="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k \ -mips mipsel mipsn32 mipsn32el mips64 mips64el \ +qemu_target_list="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" @@ -38,6 +38,10 @@ sparc32plus_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' sparc32plus_family=sparc +sparc64_magic='\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b' +sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +sparc64_family=sparc + ppc_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14' ppc_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' ppc_family=ppc From patchwork Sun May 19 20:19:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164485 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4773040ili; Sun, 19 May 2019 13:30:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxobh0rIv1FePr9I6qNKapVMhebZq9A9xF900hqCuUywb/apcJhk7kb7hbuob9snzpykSI/ X-Received: by 2002:a17:906:7e57:: with SMTP id z23mr24652862ejr.62.1558297811667; Sun, 19 May 2019 13:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558297811; cv=none; d=google.com; s=arc-20160816; b=n36H3KesrPqUobe1hZ+vEkI3J0MLdvNS+tdZJsStvutfko4OajKrQp9MgoXTOX5cIH q6j/jSkrsGxupAgM2lOaaSSjwkCrn1mg0ICLZ0cD4diJjUMgLiaUlJ5JHjlnLZfGMtOZ LSSAp0q/UJANTTWpffyDaWCGW4UqNxjvBs4TRAWNDlBRlU/9x05QauZoU0edNSTjPUzk TaUtvjj6TtOfCwr0Xmc2U6Q81z9Wp+duPGK/GqQe6klo8bwd0mD2o7HBeAKU+NkDQVL4 03Ycyg/d4mKm5s1jy0fSzU5iZgqmTlh/tKk2hDLSaZb5hygqAtZLqSK1LyTgfbAExvUd pmNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=IbY6I9DzAmMV/VMKU0boKo5CQjvFhhAqBWPLdeOiiQg=; b=NcqG5YnYQjpq+wQkeS6E69wUxgKzUVomyvz4GfJci35HIpj1IGeSkeY+QHhqZ6t82r 69fUk/4RPQ29tVByNI0W0Wm0YdYtN9itFLe5zrTDjI0b7nbrmV+nrmYkN5tulCQUdUtr LP/BPgmbmQFQm62Enb8/P2ZqqZInLSCHMgWouvcuRcJfIw3E1ghGk1z0zusUkV7ayfb+ zbbdb4YH1lKTyHJ1rygvYQiYR7Oi5auHjWj2BRYidgVTmO215zAB4CF51XYn3RAUNfZ3 zYAZBoHebmJ6+qjHqGa77GbeCv6eu936N8u+z3SlUkZ05wUcdU8qeA8KUML83QtOLkeM IoZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tEbvvc7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w14si1394345eda.226.2019.05.19.13.30.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tEbvvc7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSRe-0005W2-J3 for patch@linaro.org; Sun, 19 May 2019 16:30:10 -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) 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-Received: by 2002:a63:700b:: with SMTP id l11mr15541010pgc.449.1558297209546; 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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:08 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The error indicator for this syscall is -1, not 0. Signed-off-by: Richard Henderson --- tests/tcg/multiarch/linux-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Laurent Vivier diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.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) shmid = chk_error(shmget(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | 0777)); ptr = shmat(shmid, NULL, 0); - if (!ptr) + if (ptr == (void *)-1) { error("shmat"); + } memset(ptr, 0, SHM_SIZE); From patchwork Sun May 19 20:19:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164491 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4778955ili; Sun, 19 May 2019 13:39:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxffIV/M2WfftFUZ3f19h0vEVBFkMepRdrcbjy7JNbdRomQbpoy53ASS3df1IbxdfuR1CcC X-Received: by 2002:a17:906:60c7:: with SMTP id f7mr29734405ejk.107.1558298366292; Sun, 19 May 2019 13:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298366; cv=none; d=google.com; s=arc-20160816; b=c9WCEzzVtiqsRZirFPAbuZrQGTOYcXrGBlHerTqmx+fNkLSfP3vNG72NDIzcdHHvBr mPxE5I4lh2vaH1gASYLIkOYCYdDZccLJ7n6grOHyayI7Ss0UKryydO7ei3f+lno3bUuX dMHG5f7ONFh9j7UP2l3KoBcAmdWgpc/Tv0PUoih8PToiQiH3TRU5BWRSzhgHpuY7QOI7 onJUGUX6PBtvnRmwoKbfY2Wqa9FUi+HyK4nYT/XDkyWPDU5/NUDxJYtFArVhq9M5lGQx pY+TvZWLqh3ElzAc6J83OCVey5oOTN5tLCubsOVaqltw8mqijThYWemzxK8ACWagH/2y T9+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=SiayGyQLvWgiqh6AWRkbo8bNn33tFxS579n6WOmgYIY=; b=WDH2Mo7IKfW6UYCV8Asquf+37rt3iAxdRKPYVrv3dGI8h6F/8tzDETh7yOLqHy5QLb 0B9Dxl0AhL9s79ZP33obEYPMmtsVDncssU6eZsOQdUkzmPn9IlSaujIYvA+1eL7fSZzC XRblt3nMet7TbF3nef04+i0Fg3vgKxLYESevT+RpL007VzDpaZot/I0orrCRe3bz37Ef 6OVjwvhGpOzZmIRhtINUi8zVch9UTYWkVItfGjPniYAULFHDnQOWBBBPvyd86KuvAM6G nJGy+GkeVKYVPF29a3bws/cGqqUQrWl6V3CCguiGVZpi9FVktqJ9DbLoEMld+LNx8ABy VLCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=td151Mif; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 26si1711016ejm.371.2019.05.19.13.39.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=td151Mif; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSab-0004R9-4L for patch@linaro.org; Sun, 19 May 2019 16:39:25 -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) 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-Received: by 2002:a17:902:1126:: with SMTP id d35mr36073717pla.82.1558297210992; 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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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 old_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); 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 #include +#include #include "qemu.h" #include "disas/disas.h" @@ -2012,6 +2013,8 @@ unsigned long init_guest_space(unsigned long host_start, unsigned long guest_start, bool fixed) { + /* In order to use host shmat, we must be able to honor SHMLBA. */ + unsigned long align = MAX(SHMLBA, qemu_host_page_size); unsigned long current_start, aligned_start; int flags; @@ -2029,7 +2032,7 @@ unsigned long init_guest_space(unsigned long host_start, } /* Setup the initial flags and start address. */ - current_start = host_start & qemu_host_page_mask; + current_start = host_start & -align; flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; if (fixed) { flags |= MAP_FIXED; @@ -2065,8 +2068,8 @@ unsigned long init_guest_space(unsigned long host_start, 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 = host_full_size + qemu_host_page_size; @@ -2079,7 +2082,7 @@ unsigned long init_guest_space(unsigned long host_start, return (unsigned long)-1; } munmap((void *)real_start, real_size); - real_start = HOST_PAGE_ALIGN(real_start); + real_start = ROUND_UP(real_start, align); } current_start = real_start; } @@ -2106,7 +2109,7 @@ unsigned long init_guest_space(unsigned long host_start, } /* 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_start, if (real_start == (unsigned long)-1) { return (unsigned long)-1; } - aligned_start = HOST_PAGE_ALIGN(real_start); + aligned_start = ROUND_UP(real_start, align); } else { aligned_start = real_start; } @@ -2171,7 +2174,7 @@ unsigned long init_guest_space(unsigned long host_start, * because of trouble with ARM commpage setup. */ munmap((void *)real_start, real_size); - current_start += qemu_host_page_size; + current_start += align; if (host_start == 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; /* 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 = qemu_host_page_size; int prot; - int looped = 0; + bool looped = false; if (size > reserved_va) { return (abi_ulong)-1; } - size = HOST_PAGE_ALIGN(size); - end_addr = start + size; - if (end_addr > reserved_va) { - end_addr = reserved_va; - } - addr = end_addr - qemu_host_page_size; + /* Note that start and size have already been aligned by mmap_find_vma. */ + end_addr = start + size; + if (start > reserved_va - size) { + /* Start at the top of the address space. */ + end_addr = ((reserved_va - size) & -align) + size; + looped = true; + } + + /* Search downward from END_ADDR, checking to see if a page is in use. */ + addr = end_addr; while (1) { + addr -= incr; if (addr > end_addr) { if (looped) { + /* Failure. The entire address space has been searched. */ return (abi_ulong)-1; } - end_addr = reserved_va; - addr = end_addr - qemu_host_page_size; - looped = 1; - continue; + /* Re-start at the top of the address space. */ + addr = end_addr = ((reserved_va - size) & -align) + size; + looped = true; + } else { + prot = page_get_flags(addr); + if (prot) { + /* Page in use. Restart below this page. */ + addr = end_addr = ((addr - size) & -align) + size; + } else if (addr && addr + size == end_addr) { + /* Success! All pages between ADDR and END_ADDR are free. */ + if (start == mmap_next_start) { + mmap_next_start = addr; + } + return addr; + } } - prot = page_get_flags(addr); - if (prot) { - end_addr = addr; - } - if (addr && addr + size == end_addr) { - break; - } - addr -= qemu_host_page_size; } - - if (start == mmap_next_start) { - mmap_next_start = addr; - } - - return addr; } /* @@ -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 size) } else { start &= qemu_host_page_mask; } + start = ROUND_UP(start, align); size = HOST_PAGE_ALIGN(size); if (reserved_va) { - return mmap_find_vma_reserved(start, size); + return mmap_find_vma_reserved(start, size, align); } addr = start; @@ -299,7 +303,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) if (h2g_valid(ptr + size - 1)) { addr = h2g(ptr); - if ((addr & ~TARGET_PAGE_MASK) == 0) { + if ((addr & (align - 1)) == 0) { /* Success. */ if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) { mmap_next_start = addr + size; @@ -313,12 +317,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) /* 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 = TARGET_PAGE_ALIGN(addr); + addr = ROUND_UP(addr, align); break; case 1: /* Sometimes the kernel decides to perform the allocation at the top end of memory instead. */ - addr &= TARGET_PAGE_MASK; + addr &= -align; break; case 2: /* Start over at low memory. */ @@ -416,7 +420,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, if (!(flags & MAP_FIXED)) { host_len = len + offset - host_offset; host_len = HOST_PAGE_ALIGN(host_len); - start = mmap_find_vma(real_start, host_len); + start = mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start == (abi_ulong)-1) { errno = ENOMEM; goto fail; @@ -710,7 +714,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, } else if (flags & MREMAP_MAYMOVE) { abi_ulong mmap_start; - mmap_start = mmap_find_vma(0, new_size); + mmap_start = mmap_find_vma(0, new_size, TARGET_PAGE_SIZE); if (mmap_start == -1) { errno = 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_env, else { abi_ulong mmap_start; - mmap_start = mmap_find_vma(0, shm_info.shm_segsz); + /* In order to use the host shmat, we need to honor host SHMLBA. */ + mmap_start = mmap_find_vma(0, shm_info.shm_segsz, MAX(SHMLBA, shmlba)); if (mmap_start == -1) { errno = ENOMEM; From patchwork Sun May 19 20:19:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164488 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4776239ili; Sun, 19 May 2019 13:34:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJbpAhEdPqKUV97KbKeCqamEdkMALTN+FdFGnRJiSPeYtAX1AkXzcX4EKw5HaEFHSp37vA X-Received: by 2002:a17:906:7709:: with SMTP id q9mr55686420ejm.288.1558298097023; Sun, 19 May 2019 13:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298097; cv=none; d=google.com; s=arc-20160816; b=DnWDgh7WRtv9HVl5OK77GsCtQ5Jw6jZV7vwEuR57oWCK/vmvO5PtwYbB7gKRYkKxTh UwGZJ7Bh6UejTrOndJk3FfhHKojMyA6c/gyADW2jemy61Ojic0lSVX6Xm8mPJrAvtqHN eeORN/i5273s3IvvTU4dVxZN9x5KvWocHxJMCgBujHAyMoZBI2wKm2bIRqz4r6uRF/fE JfdJWqa7CvP0gDkf/HOem8j9md8VyNR19yMRvzEVS7MTIcMdXJd7hk9uSDZcrQYJYaJQ 6K0chmt1qKP1ZcVQ55Vo1t50Rn/+udKrCLNVcj2oNFMcLldfGchVS49BUfZbSjAaDUWp eZGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=vXq6cXFo3n3RVYR19bI6vVgQuVdOYZC397oTA+hZL94=; b=kib/s6f1eunyzo25pHCCsynHKw4pC2GJZHBjXeE4MMwuS+yoS7xxo8HJFfaavDCd7r 1yGRk+Slct2pvlU9vPk8VFkZKWCwTxDAzqbFeDawxz2NqgGPkmjzDpGqD2aRPArcdTTV 1xBJ3bUfpQh1vvCrh1nsOVE4Yt/pKUCpG8oaeo2wrNeeBKNBGLo9mt/5Zkqfzo58C4em vVGn6sAAO7tn70yvzOmNS1E/UnQzkOQRj9svQwOhQY2yqHhSP6x2pETGqjPGAdDvz0Xa VLClUqgaZROCLTVFdx2v6eoWvxtcSOh32DXg/4Ssth+sf3/6iQjZbFGWM+llxJ+i0Juc 8irQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="h/5t8SuJ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18si1152293ejf.102.2019.05.19.13.34.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="h/5t8SuJ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSWF-0000fy-WA for patch@linaro.org; Sun, 19 May 2019 16:34:56 -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) 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-Received: by 2002:a63:1e4d:: with SMTP id p13mr71552853pgm.125.1558297212217; 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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:20:11 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.17.1 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; + align = MAX(align, qemu_host_page_size); + /* If 'start' == 0, then a default start address is used. */ if (start == 0) { start = mmap_next_start;