From nobody Mon Feb 9 12:09:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1605131601; cv=none; d=zohomail.com; s=zohoarc; b=AB6KXb3GhoZxPfSSUKmMJEwrDeTqCzOBA/IH9RIPa2UknolaLvcip6iOVvaBUm0xKIlVW4TxqZmOWkMoB7TwhFB9W6k2c1vQaZ4VCq5+VJc9U9rx2rDN3PKPRDnxH38rc8SeIw6frMBaGO7F4GRrUiVFjWcqgN//K6HGiJ36/yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605131601; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sGzJpFoTaZnCaM6xOC0KlI8sjb8W5MHW3wWMiououtA=; b=Ia8u64SAMdPv+4vV2mLxcpnaB6xwM8aZIuB7g1XeYO+ouc8BHJwUp85sqt9Ks6AbABWouE3qN68pD7wGeyaIq97MoXY7mQ8mMqQhhROTO09vvujmuHx3NN1k+93jl4XZU64gDybmxE2yiLgBWztVrdftBkV+YQ/hvBmfuD5/w4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605131601751397.7328681569944; Wed, 11 Nov 2020 13:53:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.25298.52993 (Exim 4.92) (envelope-from ) id 1kcy38-0006PT-7r; Wed, 11 Nov 2020 21:53:06 +0000 Received: by outflank-mailman (output) from mailman id 25298.52993; Wed, 11 Nov 2020 21:53:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kcy38-0006PJ-2X; Wed, 11 Nov 2020 21:53:06 +0000 Received: by outflank-mailman (input) for mailman id 25298; Wed, 11 Nov 2020 21:53:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) id 1kcy36-00064v-PL for xen-devel@lists.xenproject.org; Wed, 11 Nov 2020 21:53:04 +0000 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 842d170a-abf2-4a60-8904-60b84d13b358; Wed, 11 Nov 2020 21:52:47 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id 23so4924528wmg.1 for ; Wed, 11 Nov 2020 13:52:47 -0800 (PST) Received: from C02ZJ1BNLVDN.emea.arm.com (0547a297.skybroadband.com. [5.71.162.151]) by smtp.gmail.com with ESMTPSA id u23sm4096078wmc.32.2020.11.11.13.52.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 13:52:45 -0800 (PST) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) id 1kcy36-00064v-PL for xen-devel@lists.xenproject.org; Wed, 11 Nov 2020 21:53:04 +0000 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 842d170a-abf2-4a60-8904-60b84d13b358; Wed, 11 Nov 2020 21:52:47 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id 23so4924528wmg.1 for ; Wed, 11 Nov 2020 13:52:47 -0800 (PST) Received: from C02ZJ1BNLVDN.emea.arm.com (0547a297.skybroadband.com. [5.71.162.151]) by smtp.gmail.com with ESMTPSA id u23sm4096078wmc.32.2020.11.11.13.52.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 13:52:45 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 842d170a-abf2-4a60-8904-60b84d13b358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sGzJpFoTaZnCaM6xOC0KlI8sjb8W5MHW3wWMiououtA=; b=lzrosJwBjf2JJ1R6hDwZGAfEDibeHSG4jsEPUGW4dyTwr9h7yHFIWuauR9MfE/W0Z7 kCLZ54Z/GachrPhKRopStg6qckWSh/m3aK56rgkZprKQeLZ2M1devLrjrHt+rxHD3Wil v+MwST5ssBLkCAaoKR7eRZRPGgMJYExDtRg8PrSMuPZMoGL+t6qORpwd6IaUbR14k3VM 05deiW3/TcX+UPafP9k0EiRK3dIIj9JK3wLZGssvDHwhb58dmV7CrM82ed2KPrTV4X7w 4ivCG/OzQPQL1prmrU1tnUqoWhE6TA1mrromhM60WpdfA5Zn4IkON/AlnxcuUeSIWsXa ZU8A== 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=sGzJpFoTaZnCaM6xOC0KlI8sjb8W5MHW3wWMiououtA=; b=p4Zp7ciQqTPLZrPeZwXl/g1SR6dOtuO01Yzj0VxTeX6hwT3itMx7iabZT9cDSbmVcH Iaioqft0ZkHI4wwbUcmN5LzLmfvUOIlvcetgahrVVGr8U+/ZqVZ8jOEWzhY8IPas7Hxz kFaKmVYAzHOvWH+jne0hCTfOyy35F8PSdRU47D1nVlh678sHaLDMplHoAw6mVzjysqrj GCcZCOCoYxOF9IzSswRdapoyMkuqIAHd9aRTAcOHELm54rTzl0uQjvmLwEQwoPKetiYG 8EWeGytf9iqdepgEndKmnJDQkix4joCCoAyS83H17kPlN9lkgbZtXb+Re854eygz29E1 SF9Q== X-Gm-Message-State: AOAM53127UzvnZaYcboeaHN4+Fcq/wDBh5vrv3ewGGMWayOOAlXOOgHQ bU4Ytv/z7nuZiXUxiwNSjzKJjOgVSKI= X-Google-Smtp-Source: ABdhPJwpE+zpDXpZX3INJNNQfvF/71AxIIOCQ6cvj9NkP66u4kzrVa6Nr6tLpWEWx5Vkl/8qZyMo1w== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr6509009wmj.112.1605131566282; Wed, 11 Nov 2020 13:52:46 -0800 (PST) From: Ash Wilding X-Google-Original-From: Ash Wilding To: xen-devel@lists.xenproject.org Cc: Ash Wilding , julien@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com Subject: [RFC PATCH v2 06/15] xen: port Linux to Xen Date: Wed, 11 Nov 2020 21:51:54 +0000 Message-Id: <20201111215203.80336-7-ash.j.wilding@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20201111215203.80336-1-ash.j.wilding@gmail.com> References: <20201111215203.80336-1-ash.j.wilding@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Ash Wilding - Drop kasan related helpers. - Drop READ_ONCE() and WRITE_ONCE(); the __* versions are fine for now as the only callers in Xen are the arm32 atomics helpers which are always accessing an atomic_t's counter member, which is an int. This means we can swap the arm32 atomics helpers over to using the __* versions like the arm64 code does, removing a dependency on for __native_word(). - Relax __unqual_scalar_typeof() in __READ_ONCE() to just typeof(). Similarly to above, the only callers in Xen are the arm32/arm64 atomics helpers, which are always accessing an atomic_t's counter member as a regular (int *) which doesn't need unqual'ing. This means we can remove the other dependency on . Please see previous patch in the series for expanded rationale on why not having to port to Xen makes life easier. Signed-off-by: Ash Wilding --- xen/include/xen/rwonce.h | 79 +++------------------------------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/xen/include/xen/rwonce.h b/xen/include/xen/rwonce.h index 6b47392d1c..d001e7e41e 100644 --- a/xen/include/xen/rwonce.h +++ b/xen/include/xen/rwonce.h @@ -1,90 +1,21 @@ -/* SPDX-License-Identifier: GPL-2.0 */ /* - * Prevent the compiler from merging or refetching reads or writes. The - * compiler is also forbidden from reordering successive instances of - * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some - * particular ordering. One way to make the compiler aware of ordering is = to - * put the two invocations of READ_ONCE or WRITE_ONCE in different C - * statements. + * Taken from Linux 5.10-rc2 (last commit 3cea11cd5) * - * These two macros will also work on aggregate data types like structs or - * unions. - * - * Their two major use cases are: (1) Mediating communication between - * process-level code and irq/NMI handlers, all running on the same CPU, - * and (2) Ensuring that the compiler does not fold, spindle, or otherwise - * mutilate accesses that either do not require ordering or that interact - * with an explicit memory barrier or atomic instruction that provides the - * required ordering. + * SPDX-License-Identifier: GPL-2.0 */ + #ifndef __ASM_GENERIC_RWONCE_H #define __ASM_GENERIC_RWONCE_H =20 #ifndef __ASSEMBLY__ =20 -#include -#include -#include - -/* - * Yes, this permits 64-bit accesses on 32-bit architectures. These will - * actually be atomic in some cases (namely Armv7 + LPAE), but for others = we - * rely on the access being split into 2x32-bit accesses for a 32-bit quan= tity - * (e.g. a virtual address) and a strong prevailing wind. - */ -#define compiletime_assert_rwonce_type(t) \ - compiletime_assert(__native_word(t) || sizeof(t) =3D=3D sizeof(long long)= , \ - "Unsupported access size for {READ,WRITE}_ONCE().") - -/* - * Use __READ_ONCE() instead of READ_ONCE() if you do not require any - * atomicity. Note that this may result in tears! - */ -#ifndef __READ_ONCE -#define __READ_ONCE(x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) -#endif - -#define READ_ONCE(x) \ -({ \ - compiletime_assert_rwonce_type(x); \ - __READ_ONCE(x); \ -}) +#define __READ_ONCE(x) (*(const volatile typeof(x) *)&(x)) =20 #define __WRITE_ONCE(x, val) \ do { \ *(volatile typeof(x) *)&(x) =3D (val); \ } while (0) =20 -#define WRITE_ONCE(x, val) \ -do { \ - compiletime_assert_rwonce_type(x); \ - __WRITE_ONCE(x, val); \ -} while (0) - -static __no_sanitize_or_inline -unsigned long __read_once_word_nocheck(const void *addr) -{ - return __READ_ONCE(*(unsigned long *)addr); -} - -/* - * Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need to load a - * word from memory atomically but without telling KASAN/KCSAN. This is - * usually used by unwinding code when walking the stack of a running proc= ess. - */ -#define READ_ONCE_NOCHECK(x) \ -({ \ - compiletime_assert(sizeof(x) =3D=3D sizeof(unsigned long), \ - "Unsupported access size for READ_ONCE_NOCHECK()."); \ - (typeof(x))__read_once_word_nocheck(&(x)); \ -}) - -static __no_kasan_or_inline -unsigned long read_word_at_a_time(const void *addr) -{ - kasan_check_read(addr, 1); - return *(unsigned long *)addr; -} =20 #endif /* __ASSEMBLY__ */ -#endif /* __ASM_GENERIC_RWONCE_H */ \ No newline at end of file +#endif /* __ASM_GENERIC_RWONCE_H */ --=20 2.24.3 (Apple Git-128)