public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Rong Tao <rongtao@cestc.cn>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Sasha Levin <sashal@kernel.org>,
	jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
	dave@stgolabs.net, virtualization@lists.linux-foundation.org
Subject: [PATCH AUTOSEL 6.3 28/30] tools/virtio: Fix arm64 ringtest compilation error
Date: Fri, 16 Jun 2023 06:25:16 -0400	[thread overview]
Message-ID: <20230616102521.673087-28-sashal@kernel.org> (raw)
In-Reply-To: <20230616102521.673087-1-sashal@kernel.org>

From: Rong Tao <rongtao@cestc.cn>

[ Upstream commit 57380fd1249b20ef772549af2c58ef57b21faba7 ]

Add cpu_relax() for arm64 instead of directly assert(), and add assert.h
header file. Also, add smp_wmb and smp_mb for arm64.

Compilation error as follows, avoid __always_inline undefined.

    $ make
    cc -Wall -pthread -O2 -ggdb -flto -fwhole-program -c -o ring.o ring.c
    In file included from ring.c:10:
    main.h: In function ‘busy_wait’:
    main.h:99:21: warning: implicit declaration of function ‘assert’
    [-Wimplicit-function-declaration]
    99 | #define cpu_relax() assert(0)
        |                     ^~~~~~
    main.h:107:17: note: in expansion of macro ‘cpu_relax’
    107 |                 cpu_relax();
        |                 ^~~~~~~~~
    main.h:12:1: note: ‘assert’ is defined in header ‘<assert.h>’; did you
    forget to ‘#include <assert.h>’?
    11 | #include <stdbool.h>
    +++ |+#include <assert.h>
    12 |
    main.h: At top level:
    main.h:143:23: error: expected ‘;’ before ‘void’
    143 | static __always_inline
        |                       ^
        |                       ;
    144 | void __read_once_size(const volatile void *p, void *res, int
    size)
        | ~~~~
    main.h:158:23: error: expected ‘;’ before ‘void’
    158 | static __always_inline void __write_once_size(volatile void *p,
    void *res, int size)
        |                       ^~~~~
        |                       ;
    make: *** [<builtin>: ring.o] Error 1

Signed-off-by: Rong Tao <rongtao@cestc.cn>
Message-Id: <tencent_F53E159DD7925174445D830DA19FACF44B07@qq.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/virtio/ringtest/main.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/virtio/ringtest/main.h b/tools/virtio/ringtest/main.h
index b68920d527503..d18dd317e27f9 100644
--- a/tools/virtio/ringtest/main.h
+++ b/tools/virtio/ringtest/main.h
@@ -8,6 +8,7 @@
 #ifndef MAIN_H
 #define MAIN_H
 
+#include <assert.h>
 #include <stdbool.h>
 
 extern int param;
@@ -95,6 +96,8 @@ extern unsigned ring_size;
 #define cpu_relax() asm ("rep; nop" ::: "memory")
 #elif defined(__s390x__)
 #define cpu_relax() barrier()
+#elif defined(__aarch64__)
+#define cpu_relax() asm ("yield" ::: "memory")
 #else
 #define cpu_relax() assert(0)
 #endif
@@ -112,6 +115,8 @@ static inline void busy_wait(void)
 
 #if defined(__x86_64__) || defined(__i386__)
 #define smp_mb()     asm volatile("lock; addl $0,-132(%%rsp)" ::: "memory", "cc")
+#elif defined(__aarch64__)
+#define smp_mb()     asm volatile("dmb ish" ::: "memory")
 #else
 /*
  * Not using __ATOMIC_SEQ_CST since gcc docs say they are only synchronized
@@ -136,10 +141,16 @@ static inline void busy_wait(void)
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__s390x__)
 #define smp_wmb() barrier()
+#elif defined(__aarch64__)
+#define smp_wmb() asm volatile("dmb ishst" ::: "memory")
 #else
 #define smp_wmb() smp_release()
 #endif
 
+#ifndef __always_inline
+#define __always_inline inline __attribute__((always_inline))
+#endif
+
 static __always_inline
 void __read_once_size(const volatile void *p, void *res, int size)
 {
-- 
2.39.2


  parent reply	other threads:[~2023-06-16 10:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 10:24 [PATCH AUTOSEL 6.3 01/30] Input: soc_button_array - add invalid acpi_index DMI quirk handling Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 02/30] arm64: dts: qcom: sc7280-idp: drop incorrect dai-cells from WCD938x SDW Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 03/30] arm64: dts: qcom: sc7280-qcard: " Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 04/30] s390/cio: unregister device when the only path is gone Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 05/30] spi: lpspi: disable lpspi module irq in DMA mode Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 06/30] ASoC: codecs: wcd938x-sdw: do not set can_multi_write flag Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 07/30] ASoC: simple-card: Add missing of_node_put() in case of error Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 08/30] soundwire: dmi-quirks: add new mapping for HP Spectre x360 Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 09/30] soundwire: qcom: add proper error paths in qcom_swrm_startup() Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 10/30] platform/x86: int3472: Avoid crash in unregistering regulator gpio Sasha Levin
2023-06-16 10:24 ` [PATCH AUTOSEL 6.3 11/30] ASoC: nau8824: Add quirk to active-high jack-detect Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 12/30] ASoC: amd: yc: Add Thinkpad Neo14 to quirks list for acp6x Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 13/30] drm/ast: Fix modeset failed on DisplayPort Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 14/30] gfs2: Don't get stuck writing page onto itself under direct I/O Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 15/30] s390/purgatory: disable branch profiling Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 16/30] ASoC: fsl_sai: Enable BCI bit if SAI works on synchronous mode with BYP asserted Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 17/30] net: sched: wrap tc_skip_wrapper with CONFIG_RETPOLINE Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 18/30] ALSA: hda/realtek: Add "Intel Reference board" and "NUC 13" SSID in the ALC256 Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 19/30] i2c: mchp-pci1xxxx: Avoid cast to incompatible function type Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 20/30] i2c: designware: fix idx_write_cnt in read loop Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 21/30] ARM: dts: Fix erroneous ADS touchscreen polarities Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 22/30] null_blk: Fix: memory release when memory_backed=1 Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 23/30] drm/exynos: vidi: fix a wrong error return Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 24/30] drm/exynos: fix race condition UAF in exynos_g2d_exec_ioctl Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 25/30] drm/radeon: fix race condition UAF in radeon_gem_set_domain_ioctl Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 26/30] Revert "ext4: don't clear SB_RDONLY when remounting r/w until quota is re-enabled" Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 27/30] ext4: only check dquot_initialize_needed() when debugging Sasha Levin
2023-06-16 10:25 ` Sasha Levin [this message]
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 29/30] vhost_vdpa: tell vqs about the negotiated Sasha Levin
2023-06-16 10:25 ` [PATCH AUTOSEL 6.3 30/30] vhost_net: revert upend_idx only on retriable error Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230616102521.673087-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=rongtao@cestc.cn \
    --cc=stable@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox