From patchwork Tue Jul 9 09:20:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 168731 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8295220ilk; Tue, 9 Jul 2019 02:23:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAtdpIEwBl4IqyR0A9QiKGKETOTyoTYzMGfHlh+7AcFQg38d8J0GodGW68v30/H+aDD2R7 X-Received: by 2002:a17:906:7281:: with SMTP id b1mr20718561ejl.63.1562664186384; Tue, 09 Jul 2019 02:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562664186; cv=none; d=google.com; s=arc-20160816; b=IiQEoVMzmtozFaPoT9KA7Bp/VS/SaSo+Qa18Poz0EWkCTBhTnWnZQJfyx2L73CmMGW 790P78RI2/b2k4vt5dqJLWta8KQOQxP93AGO3AFy0rF1AdGx7EQ9qZO6UJjkhwjTk6Ix wryUarT+Pm24SatUR1vCvaERvby9kiYiK8S5cUGtDp/kyS2sNbaDbkS0Rpgot2MK7uQ4 xYWx83UkPumY5fFwF9yskWkoLVNP4zZ2jRE0YgAvtftHAnbo+wncwbyE7Su6m84aYhQ5 3OvmDLgErgmhP8lqdqcTgPLIjW23BErBAst/jLfca8iRFe2SDwyEy6TZNkqUlNGu0Cjr keNw== 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=pFoay7GNwEUZQB8Jr0UsvPyxNWVYPlqTjcJEEwVExaY=; b=p48JNBOWkxgF4Br3C01sGQl/shdQ19PNPIv5wN1ngPHK/LnXdwf7ZOihJVYvCgWjZS o9G2CJ6o9q9sAwJUVWdyWPaiyG+TP2fsdy9GjLRTPRk3yG+Rf4cpPk5L0q6Jl1vB60eI ZVN+mT8qtbeRr6QHHtWtRMBEv5ec2/qekEqJzQ1KTS9tV+CNWr5rnxmEndQUvugnBSp0 u1Mw6bfIQgVoygG1a9B+GcPzKt0YxMOmT/gc4jvNNehmwqlh+W/fggIXWIu+tQJWISg2 URlh9kXowYZ6HDjlIBtcfPjv19hKgU9bKN8875mij4dxlaU0v21MifrE2eF04dd+5bzO Ud6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zud4XPcZ; 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 h18si15234503edb.3.2019.07.09.02.23.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2019 02:23:06 -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=zud4XPcZ; 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 ([::1]:48076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkmL3-0000vT-8h for patch@linaro.org; Tue, 09 Jul 2019 05:23:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43403) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkmJA-0006qC-Mw for qemu-devel@nongnu.org; Tue, 09 Jul 2019 05:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkmJ8-0001mu-Ng for qemu-devel@nongnu.org; Tue, 09 Jul 2019 05:21:08 -0400 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]:37371) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkmJ8-0001mR-9q for qemu-devel@nongnu.org; Tue, 09 Jul 2019 05:21:06 -0400 Received: by mail-io1-xd42.google.com with SMTP id q22so19834010iog.4 for ; Tue, 09 Jul 2019 02:21: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=pFoay7GNwEUZQB8Jr0UsvPyxNWVYPlqTjcJEEwVExaY=; b=zud4XPcZjkg3qLwJfacPY/UrNy72sXWazemnvyWdT7kcJwisiQhcP9GCwnaLfa1KUV jQYBNRfykwriAewJCJ4CF9x0Ip3rIUioQQkLcmgnW3q5jzs+Gt8tPDruYFuegUstpxq5 ZmjM+SO9CPWFljrBCjzn1U1wi7HLy8xJIuHIS7bj02n8zPIUeCUCS4EcfGb5WbguyuK9 pU4aIMEJMGLDqFtUgXeiV904DXy1zJj27XaX1VhtQXDw+eCIzpae1uJ1YuD5Ny2PBJJO bD5AGjPAKUO2eog2p4aGd5dIEp0c7N3DuEBq8GwvNB82f40UIfHhSrvnJ5NIRLWj6V4P vqgg== 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=pFoay7GNwEUZQB8Jr0UsvPyxNWVYPlqTjcJEEwVExaY=; b=crmD3IKV29Tcd20lNIPntl5PJzUqKz5Fo5rthNfNyE/eK6eCDH3hBXg9VYcPKg5zPv Kxt+3zy7AwdcQbXTixtjm4R9/0sVkJzx1nP+mJf3YHSxX8hAnAZ6D4rOVfXlRrx7rirO jUBrxAS2KZm9r8RJ/FsT5hAP4pV/rrFBKe9c61PgNGyn7udg6kGL4fe/7h7UgG5RjQpY DXDRqjzTMd0bCfzZ3OjS9N/2OIOmyEcxr5RqzzP9KXvtRHYktzDlR9oYjxZ2xl+BYPYz o1neggBoB2rkVBMXipboM5ZngKlTD5K/6Hra53n5Zef/XfHwqpjRpl8VioLTJXHPi5Od NBLw== X-Gm-Message-State: APjAAAV7h70RlMkZ0zc4W4s7N0Kas5aztG7CaSPeJTh7IDhTr6K4I//x 9iXlCUrS1Ype9FFa/lexALsdbVJmjO8= X-Received: by 2002:a02:c549:: with SMTP id g9mr18876778jaj.14.1562664065166; Tue, 09 Jul 2019 02:21:05 -0700 (PDT) Received: from localhost.localdomain ([172.56.12.212]) by smtp.gmail.com with ESMTPSA id c17sm17613817ioo.82.2019.07.09.02.21.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 02:21:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 9 Jul 2019 11:20:45 +0200 Message-Id: <20190709092049.13771-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190709092049.13771-1-richard.henderson@linaro.org> References: <20190709092049.13771-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::d42 Subject: [Qemu-devel] [PATCH 1/5] include/qemu/atomic.h: Add signal_barrier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, peter.maydell@linaro.org, alex.bennee@linaro.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have some potential race conditions vs our user-exec signal handler that will be solved with this barrier. Signed-off-by: Richard Henderson --- include/qemu/atomic.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index a6ac188188..f9cd24c899 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -88,6 +88,13 @@ #define smp_read_barrier_depends() barrier() #endif +/* + * A signal barrier forces all pending local memory ops to be observed before + * a SIGSEGV is delivered to the *same* thread. In practice this is exactly + * the same as barrier(), but since we have the correct builtin, use it. + */ +#define signal_barrier() __atomic_signal_fence(__ATOMIC_SEQ_CST) + /* Sanity check that the size of an atomic operation isn't "overly large". * Despite the fact that e.g. i686 has 64-bit atomic operations, we do not * want to use them because we ought not need them, and this lets us do a @@ -308,6 +315,10 @@ #define smp_read_barrier_depends() barrier() #endif +#ifndef signal_barrier +#define signal_barrier() barrier() +#endif + /* These will only be atomic if the processor does the fetch or store * in a single issue memory operation */