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: 927302 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Mld8gU4+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 413N695DfWz9s1B for ; Sun, 10 Jun 2018 14:12:49 +1000 (AEST) Received: from localhost ([::1]:42565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrih-0006Yk-6t for incoming@patchwork.ozlabs.org; Sun, 10 Jun 2018 00:12:47 -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-Google-Smtp-Source: ADUXVKLpaKrUpfsvZy7/gwwRerUQFXvWjms1lIycrJS0j6oU0eEGYC/YoNEua/bl8EOqc1bkXwj3hw== 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+incoming=patchwork.ozlabs.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(-) 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