From patchwork Sun Jun 10 03:02:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138171 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2612825lji; Sat, 9 Jun 2018 21:12:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdSuXNHKfloDV32y+qiVGI0PMvRAZRBCLRdGMP27qcLC9BCg8mf96ayJtLsR2uxm1B98FG X-Received: by 2002:ac8:3661:: with SMTP id n30-v6mr11935414qtb.1.1528603952363; Sat, 09 Jun 2018 21:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603952; cv=none; d=google.com; s=arc-20160816; b=e3+jtJAwS75wtfzhm8fvp1/cqUIN5My/wYW+hx2LRpAt8DepK4k8MQx1dgqkbWuGFb Bydu73GY9325UEBYrCLImmkZmmMHVxhVy3TWXfJyM2nmmfnYVZg2hSeNxYmsUP5z01LO gxSgZHRKyhMTJlqI3PS7LieDRd9PQ5Jx4MhWQ3MwHHlIpGvDOXKp/fkMr/ocnnnSAK1c 7Cb3FC0uHZ5UppgO4pEfG06WgUKr+Jpz1qR0eEXA2xLktDLsBE0F83YEXhUmdiOcLUqf vbRjkvcLIyDCYYt4rLVp0h2Zr2biD5NaGG4I69jgYE5chldWORGbSvTnay3yifygl3WR 1uuw== 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:arc-authentication-results; bh=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=od53ZOY5Ovv9W27wCnUy00/73nvY7+wHoWSajc40sNb4SZBTQHpg80lGgDpbJSuws2 OPCyQuuIrixugPfwkEasVmUkARC6J9GUbtYLmJMlHqUo6f+/ylt/77q+JQqjbDHPMOq1 c1Pa/SIg7aUWwJJU+k3k25ZgJlQn3oeZHkcqwrC+fDDFgqjoz+SP6YXKM+xaj8JjEsCN be+6o7AO6TkMk5sz8ZAhdW79pvUSTNNqbBY+uSLueSbh5MMGvYCY2WFJ4COxCm9EvW82 KB+D4eksHOEcZav6JYEbPk2Bd6qgG0vjl7SeYwCYQtP6NixMuiRqsPcx1bhRQE8unfjN eRCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Mld8gU4+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w42-v6si233661qtc.68.2018.06.09.21.12.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Mld8gU4+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRriR-0006Yk-NU for patch@linaro.org; Sun, 10 Jun 2018 00:12:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg4-0004j4-3R for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg0-0004oL-UM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:00 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:38805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg0-0004o4-Nw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:56 -0400 Received: by mail-pl0-x242.google.com with SMTP id b14-v6so10402273pls.5 for ; Sat, 09 Jun 2018 20:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=Mld8gU4+KSoNv8CdiXtrrUPovmKUxAAXhWoR9eqgX1r+yxUAtq2MFOcGr9Bx+H6i2X 692V9yTSXtXEN6XyQcqRlKJ3yv/Voxr6GQpTqfGAF9lkWK6t5+L65fWxnRi2Z4LfpbIb OQz+KPEVME/Pndh+6xAYo2kUBMSzLZiSt2MqE= 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=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=J1FD8ODq6MjNSF5pkudmH0jjscS261cdK9yErhQrzZNXW4PNmhyudPeAoniLMg1oBr MO9MVd1RADyPM6l9lUpmF5tAUlo0H3/N6mgR8cdhR2dJQYB5M9kfbshpCuY/mFz7q593 9YJYL/Z+F34f2OrlhuuriJrjKcTrDI+W5rWZjkyf58Pcl0MCTlmqgmHeP/pbqlV2uIgC WNgV3zvyZw28fhk9Kfkqck/boQaPWfUIzceRebvft8YvDVuUYOcE6aHmkgB7gicSur8r Xwec7enjGX8t5f94HM1w+ai9thWwv9ECMTYJN1k2k7VEMB00dkWWLJ/TTgPYVVrR6KVV f6gQ== X-Gm-Message-State: APt69E3MPWEs119BqIGfa5qsLLTaTWpI1oX3F1EaIQryWgRs2ioGf8Uz oFtP/8sODzcwIlsquYJG541PEDNzBXc= X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr12816038plb.296.1528599955660; Sat, 09 Jun 2018 20:05:55 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:15 -1000 Message-Id: <20180610030220.3777-104-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 103/108] linux-user: Split out atomic_cmpxchg_32 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" At the same time, make it atomic. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 47 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f898e70e98..5d60872587 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7560,6 +7560,29 @@ IMPL(atomic_barrier) } #endif +#ifdef TARGET_NR_atomic_cmpxchg_32 +IMPL(atomic_cmpxchg_32) +{ + /* This is m68k specific. */ + uint32_t newval = arg1; + uint32_t oldval = arg2; + abi_ulong target_addr = arg6; + uint32_t *host_addr; + + if (!access_ok(VERIFY_WRITE, target_addr, 4)) { + target_siginfo_t info; + info.si_signo = SIGSEGV; + info.si_errno = 0; + info.si_code = TARGET_SEGV_MAPERR; + info._sifields._sigfault._addr = target_addr; + queue_signal(cpu_env, info.si_signo, QEMU_SI_FAULT, &info); + return 0xdeadbeef; + } + host_addr = g2h(target_addr); + return atomic_cmpxchg(host_addr, oldval, newval); +} +#endif + #ifdef TARGET_NR_bind IMPL(bind) { @@ -13025,27 +13048,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_atomic_cmpxchg_32 - case TARGET_NR_atomic_cmpxchg_32: - { - /* should use start_exclusive from main.c */ - abi_ulong mem_value; - if (get_user_u32(mem_value, arg6)) { - target_siginfo_t info; - info.si_signo = SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = arg6; - queue_signal((CPUArchState *)cpu_env, info.si_signo, - QEMU_SI_FAULT, &info); - ret = 0xdeadbeef; - - } - if (mem_value == arg2) - put_user_u32(arg1, arg6); - return mem_value; - } -#endif #ifdef TARGET_NR_timer_create case TARGET_NR_timer_create: { @@ -13299,6 +13301,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_atomic_barrier SYSCALL(atomic_barrier); +#endif +#ifdef TARGET_NR_atomic_cmpxchg_32 + SYSCALL(atomic_cmpxchg_32); #endif SYSCALL(brk); #ifdef TARGET_NR_cacheflush