From patchwork Sun Jul 14 11:12: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: 168964 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3117236ilk; Sun, 14 Jul 2019 04:13:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBnIWOtvjjGvWG2L1qv4oCA8+HFV7hjlSV093bIlFGy2Rp4fCLFTWPLZjwPd4X8UxRhbfh X-Received: by 2002:a17:906:d052:: with SMTP id bo18mr11499622ejb.311.1563102784463; Sun, 14 Jul 2019 04:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563102784; cv=none; d=google.com; s=arc-20160816; b=xZeeLcPE8RZtOaqYGnPGmL9kBsYSdglFoHtab6awcvDfWvaMZvuYtFYNZO/D0XaVOV 90EbM0nfYkKIoottPEUs5QCEFhKZMSInp3fRTklPhiMyqzY4qabChLFMxZwUy8InSqFA S3OQ+88EUOV/cbEAREFNGt+7s7SRzhY4mrVlQ5TiHQVwyuz9C+bSOuF9bu65U2UvI4bV w1qyUDY+2FRO3F1jY5RvIgrSPLj28EVeeTbGfTWoZNM1M/KbJdMdy2mSaZC0Khf2AWmx a9HSthf5FHgfUfrAymtZI9ItF79UXekPgjbOR0MUX8J3msXmEfUCrlNiix0tZK/cx/P4 vabg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=IU6CpUk80Z4mC25brxsmW3vPt8EDvL+ViVtQOkol+IoQr3+FJMazE8oRDYIPzJjvX9 bpvjUEoaaxsqfC3mX/hYDw2RJagpYiZ9WMdT6hiNiTgg/mEXXlY6RGcLW4t1UocsF6gK kMVQCkyXRS+EdVYjxrXp1xsrsrVyheRcIQtlGvSrE4ac+sL0KnLfHJM5muXjHQsm5rhM cO1Xk6PXL52qUBq2voDzs5y5caKRtlpC81PNJGcqzNqguMdKNDHxXZFm3qGwdXWIO5ei K3CQ9q/33YgB4n3U/aOZQ9pO5DsQmAK8OkwprDpH23V5yrM8cBLmSQH6Pl0q5M8q14XR VerA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eWNh56k9; 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 l31si9819563edc.248.2019.07.14.04.13.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Jul 2019 04:13:04 -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=eWNh56k9; 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]:59730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcRC-0005db-OE for patch@linaro.org; Sun, 14 Jul 2019 07:13:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60329) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmcR6-0005WB-9i for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmcR5-0006Ms-Au for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:56 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmcR5-0006Me-4O for qemu-devel@nongnu.org; Sun, 14 Jul 2019 07:12:55 -0400 Received: by mail-wr1-x442.google.com with SMTP id n4so14178818wrs.3 for ; Sun, 14 Jul 2019 04:12:55 -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 :mime-version:content-transfer-encoding; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=eWNh56k93wj+RmSdz9aRxl3EMTH1CZOzmYQtY7HwH4K6XbyLBVGryCpg08oI3eD1pF ivcEGZwDO0cUkWJXy/rKojvMY/nmKVXvGX+GslGGkBLR0XHju/pKqnWA4k3s2mU09/6k qRI8OcCDSwCT1Tktma9XJ8mJBi3jAthYyP2k3gIstLrRDiF6dysGamhUr8ZtdnblOs1n bcEAZuiNb/D4bkHP/MxQ/+WN0UvmSxqvgTuxhBCKa2SbJiHtlPIFEu/5kWMtMwFzPF8Z WotIGWuj9zxh4NAlwe2Z4MCC+7Du7ZDik14kFsMFBGP67BSR7/+gctzHGkMo4++d6ubj SpXg== 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:mime-version:content-transfer-encoding; bh=PPHqcOU6slcSwGsgrcyJjEFtFg9+d324ttSckt/Z6xM=; b=o+vsQDv92qZHkAc36fiOR0nb71DRsjPc7WhfPGDSLU9hfxAx4iNGVZQVsUkohmiQVZ tPNVlWxJuOLecgZxDiFfRNvzMZt+Erbdt1N/u1jQfXFJsHEXzliDPzC1jalJDIE0Z2iq lrmtNfeSzVqq4yBUwMABcmLF8avLNOKQZo/w7Y8i+huA8iBJax0dQjU2qqQrCUlQI6IN 9moEdfcPh9JSZ8dU57mAl44HDaGaO0m/duR7wnjN/nc0WsW3y5GAJ/rgPM+OoIj1PNV7 WDKiun6ZFuAXS453JFQqdiD7iYHIwlkTWt4+342cxEbLcJxapaKH8KC08Sw6lswOML7O LAcA== X-Gm-Message-State: APjAAAUjNyx4Qbe3nfB51m6OZQaGTd0003PKIWVDkP4JkoIjcsHhMy2F qB2sWlPc+We3l+4QhXWNakYR9bQ0hvSHCg== X-Received: by 2002:a5d:4309:: with SMTP id h9mr22181473wrq.221.1563102774015; Sun, 14 Jul 2019 04:12:54 -0700 (PDT) Received: from localhost.localdomain ([194.144.248.241]) by smtp.gmail.com with ESMTPSA id f17sm12675795wmf.27.2019.07.14.04.12.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 14 Jul 2019 04:12:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 14 Jul 2019 11:12:45 +0000 Message-Id: <20190714111249.13859-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190714111249.13859-1-richard.henderson@linaro.org> References: <20190714111249.13859-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL for-4.1 3/7] 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: peter.maydell@linaro.org 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/qemu/atomic.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.17.1 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 */