2024-02-19 15:40:50

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 00/10] vdso: Misc cleanups and prevent code duplication

Hi,

the vdso related cleanup queue contains two parts:

- Patch 1-3: Misc cleanups related to a comment, a superfluous header
include and ifdeffery

- Patch 4-10: The union vdso_data_store is defined in seven
architectures. Make this union available in a generic vdso
header file to prevent code duplication and fix the
architectures one by one to use the generic vdso_data_store.

Thanks,

Anna-Maria


Anna-Maria Behnsen (10):
vdso/helpers: Fix grammar in comments
s390/vdso/data: Drop unnecessary header include
csky/vdso: Remove superfluous ifdeffery
vdso/arm: make union vdso_data_store available for all
arm64/vdso: Use generic union vdso_data_store
riscv/vdso: Use generic union vdso_data_store
s390/vdso: Use generic union vdso_data_store
loongarch/vdso: Use generic union vdso_data_store
mips/vdso: Use generic union vdso_data_store
csky/vdso: Use generic union vdso_data_store

arch/arm/include/asm/elf.h | 1 -
arch/arm/include/asm/vdso_datapage.h | 26 --------------------------
arch/arm/kernel/asm-offsets.c | 4 +++-
arch/arm/kernel/vdso.c | 4 ----
arch/arm64/kernel/vdso.c | 5 +----
arch/csky/include/asm/vdso.h | 5 -----
arch/csky/kernel/vdso.c | 14 ++------------
arch/loongarch/kernel/vdso.c | 6 ++----
arch/mips/include/asm/vdso.h | 5 -----
arch/mips/kernel/vdso.c | 2 +-
arch/riscv/kernel/vdso.c | 8 +-------
arch/s390/include/asm/vdso/data.h | 1 -
arch/s390/kernel/vdso.c | 5 +----
include/vdso/datapage.h | 10 ++++++++++
include/vdso/helpers.h | 8 ++++----
15 files changed, 25 insertions(+), 79 deletions(-)
delete mode 100644 arch/arm/include/asm/vdso_datapage.h

--
2.39.2



2024-02-19 15:40:51

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 04/10] vdso/arm: make union vdso_data_store available for all

The vDSO data page "union vdso_data_store" is defined in an arm header file
and also defined in several other places.

Move the definition from arm header file into the generic vdso datapage
header to make it also usable for others and to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Russell King <[email protected]>
Cc: Eric Biederman <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
arch/arm/include/asm/elf.h | 1 -
arch/arm/include/asm/vdso_datapage.h | 26 --------------------------
arch/arm/kernel/asm-offsets.c | 4 +++-
arch/arm/kernel/vdso.c | 4 ----
include/vdso/datapage.h | 10 ++++++++++
5 files changed, 13 insertions(+), 32 deletions(-)
delete mode 100644 arch/arm/include/asm/vdso_datapage.h

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index d68101655b74..9f21e170320f 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -4,7 +4,6 @@

#include <asm/auxvec.h>
#include <asm/hwcap.h>
-#include <asm/vdso_datapage.h>

/*
* ELF register definitions..
diff --git a/arch/arm/include/asm/vdso_datapage.h b/arch/arm/include/asm/vdso_datapage.h
deleted file mode 100644
index bef68f59928d..000000000000
--- a/arch/arm/include/asm/vdso_datapage.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Adapted from arm64 version.
- *
- * Copyright (C) 2012 ARM Limited
- */
-#ifndef __ASM_VDSO_DATAPAGE_H
-#define __ASM_VDSO_DATAPAGE_H
-
-#ifdef __KERNEL__
-
-#ifndef __ASSEMBLY__
-
-#include <vdso/datapage.h>
-#include <asm/page.h>
-
-union vdso_data_store {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-};
-
-#endif /* !__ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif /* __ASM_VDSO_DATAPAGE_H */
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 219cbc7e5d13..4915662842ff 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -21,10 +21,12 @@
#include <asm/mpu.h>
#include <asm/procinfo.h>
#include <asm/suspend.h>
-#include <asm/vdso_datapage.h>
#include <asm/hardware/cache-l2x0.h>
#include <linux/kbuild.h>
#include <linux/arm-smccc.h>
+
+#include <vdso/datapage.h>
+
#include "signal.h"

/*
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index f297d66a8a76..d499ad461b00 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -21,7 +21,6 @@
#include <asm/cacheflush.h>
#include <asm/page.h>
#include <asm/vdso.h>
-#include <asm/vdso_datapage.h>
#include <clocksource/arm_arch_timer.h>
#include <vdso/helpers.h>
#include <vdso/vsyscall.h>
@@ -35,9 +34,6 @@ extern char vdso_start[], vdso_end[];
/* Total number of pages needed for the data and text portions of the VDSO. */
unsigned int vdso_total_pages __ro_after_init;

-/*
- * The VDSO data page.
- */
static union vdso_data_store vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = vdso_data_store.data;

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 73eb622e7663..7ba44379a095 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -19,6 +19,8 @@
#include <vdso/time32.h>
#include <vdso/time64.h>

+#include <asm/page.h>
+
#ifdef CONFIG_ARCH_HAS_VDSO_DATA
#include <asm/vdso/data.h>
#else
@@ -121,6 +123,14 @@ struct vdso_data {
extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden")));
extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden")));

+/**
+ * union vdso_data_store - Generic vDSO data page
+ */
+union vdso_data_store {
+ struct vdso_data data[CS_BASES];
+ u8 page[PAGE_SIZE];
+};
+
/*
* The generic vDSO implementation requires that gettimeofday.h
* provides:
--
2.39.2


2024-02-19 15:40:53

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 01/10] vdso/helpers: Fix grammar in comments

Signed-off-by: Anna-Maria Behnsen <[email protected]>
---
include/vdso/helpers.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h
index 9a2af9fca45e..73501149439d 100644
--- a/include/vdso/helpers.h
+++ b/include/vdso/helpers.h
@@ -30,9 +30,9 @@ static __always_inline u32 vdso_read_retry(const struct vdso_data *vd,
static __always_inline void vdso_write_begin(struct vdso_data *vd)
{
/*
- * WRITE_ONCE it is required otherwise the compiler can validly tear
+ * WRITE_ONCE() is required otherwise the compiler can validly tear
* updates to vd[x].seq and it is possible that the value seen by the
- * reader it is inconsistent.
+ * reader is inconsistent.
*/
WRITE_ONCE(vd[CS_HRES_COARSE].seq, vd[CS_HRES_COARSE].seq + 1);
WRITE_ONCE(vd[CS_RAW].seq, vd[CS_RAW].seq + 1);
@@ -43,9 +43,9 @@ static __always_inline void vdso_write_end(struct vdso_data *vd)
{
smp_wmb();
/*
- * WRITE_ONCE it is required otherwise the compiler can validly tear
+ * WRITE_ONCE() is required otherwise the compiler can validly tear
* updates to vd[x].seq and it is possible that the value seen by the
- * reader it is inconsistent.
+ * reader is inconsistent.
*/
WRITE_ONCE(vd[CS_HRES_COARSE].seq, vd[CS_HRES_COARSE].seq + 1);
WRITE_ONCE(vd[CS_RAW].seq, vd[CS_RAW].seq + 1);
--
2.39.2


2024-02-19 15:40:56

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 02/10] s390/vdso/data: Drop unnecessary header include

vdso/datapage.h includes the arch specific vdso/data.h file. So there is no
need to do it also the other way round and including the generic
vdso/datapage.h file inside the arch specific data.h file.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: [email protected]
---
arch/s390/include/asm/vdso/data.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/s390/include/asm/vdso/data.h b/arch/s390/include/asm/vdso/data.h
index 73ee89142666..0e2b40ef69b0 100644
--- a/arch/s390/include/asm/vdso/data.h
+++ b/arch/s390/include/asm/vdso/data.h
@@ -3,7 +3,6 @@
#define __S390_ASM_VDSO_DATA_H

#include <linux/types.h>
-#include <vdso/datapage.h>

struct arch_vdso_data {
__s64 tod_steering_delta;
--
2.39.2


2024-02-19 15:41:21

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 08/10] loongarch/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: [email protected]
---
arch/loongarch/kernel/vdso.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
index 14941e4be66d..90dfccb41c14 100644
--- a/arch/loongarch/kernel/vdso.c
+++ b/arch/loongarch/kernel/vdso.c
@@ -21,15 +21,13 @@
#include <asm/vdso.h>
#include <vdso/helpers.h>
#include <vdso/vsyscall.h>
+#include <vdso/datapage.h>
#include <generated/vdso-offsets.h>

extern char vdso_start[], vdso_end[];

/* Kernel-provided data used by the VDSO. */
-static union {
- u8 page[PAGE_SIZE];
- struct vdso_data data[CS_BASES];
-} generic_vdso_data __page_aligned_data;
+static union vdso_data_store generic_vdso_data __page_aligned_data;

static union {
u8 page[LOONGARCH_VDSO_DATA_SIZE];
--
2.39.2


2024-02-19 15:41:32

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 09/10] mips/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]
---
arch/mips/include/asm/vdso.h | 5 -----
arch/mips/kernel/vdso.c | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/mips/include/asm/vdso.h b/arch/mips/include/asm/vdso.h
index cc7b516129a8..afb03d45bcd0 100644
--- a/arch/mips/include/asm/vdso.h
+++ b/arch/mips/include/asm/vdso.h
@@ -50,9 +50,4 @@ extern struct mips_vdso_image vdso_image_o32;
extern struct mips_vdso_image vdso_image_n32;
#endif

-union mips_vdso_data {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-};
-
#endif /* __ASM_VDSO_H */
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index f6d40e43f108..dda36fa26307 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -24,7 +24,7 @@
#include <vdso/vsyscall.h>

/* Kernel-provided data used by the VDSO. */
-static union mips_vdso_data mips_vdso_data __page_aligned_data;
+static union vdso_data_store mips_vdso_data __page_aligned_data;
struct vdso_data *vdso_data = mips_vdso_data.data;

/*
--
2.39.2


2024-02-19 15:41:32

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 05/10] arm64/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
---
arch/arm64/kernel/vdso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 5562daf38a22..89b6e7840002 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -69,10 +69,7 @@ static struct vdso_abi_info vdso_info[] __ro_after_init = {
/*
* The vDSO data page.
*/
-static union {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = vdso_data_store.data;

static int vdso_mremap(const struct vm_special_mapping *sm,
--
2.39.2


2024-02-19 15:41:41

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 07/10] s390/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: [email protected]
---
arch/s390/kernel/vdso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index bbaefd84f15e..a45b3a4c91db 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -25,10 +25,7 @@ extern char vdso32_start[], vdso32_end[];

static struct vm_special_mapping vvar_mapping;

-static union {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
+static union vdso_data_store vdso_data_store __page_aligned_data;

struct vdso_data *vdso_data = vdso_data_store.data;

--
2.39.2


2024-02-19 15:41:48

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 10/10] csky/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Guo Ren <[email protected]>
Cc: [email protected]
---
arch/csky/kernel/vdso.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/csky/kernel/vdso.c b/arch/csky/kernel/vdso.c
index e74a2504d331..2ca886e4a458 100644
--- a/arch/csky/kernel/vdso.c
+++ b/arch/csky/kernel/vdso.c
@@ -15,14 +15,8 @@ extern char vdso_start[], vdso_end[];
static unsigned int vdso_pages;
static struct page **vdso_pagelist;

-/*
- * The vDSO data page.
- */
-static union {
- struct vdso_data data;
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
-struct vdso_data *vdso_data = &vdso_data_store.data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
+struct vdso_data *vdso_data = vdso_data_store.data;

static int __init vdso_init(void)
{
--
2.39.2


2024-02-19 15:51:12

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH 06/10] riscv/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: [email protected]
---
arch/riscv/kernel/vdso.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index 2cf76218a5bd..100cdea6d3e3 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -30,13 +30,7 @@ enum rv_vdso_map {

#define VVAR_SIZE (VVAR_NR_PAGES << PAGE_SHIFT)

-/*
- * The vDSO data page.
- */
-static union {
- struct vdso_data data;
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = &vdso_data_store.data;

struct __vdso_info {
--
2.39.2


2024-02-19 16:22:28

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH 02/10] s390/vdso/data: Drop unnecessary header include

On Mon, Feb 19, 2024 at 04:39:31PM +0100, Anna-Maria Behnsen wrote:
> vdso/datapage.h includes the arch specific vdso/data.h file. So there is no
> need to do it also the other way round and including the generic
> vdso/datapage.h file inside the arch specific data.h file.
>
> Signed-off-by: Anna-Maria Behnsen <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: [email protected]
> ---
> arch/s390/include/asm/vdso/data.h | 1 -
> 1 file changed, 1 deletion(-)

Acked-by: Heiko Carstens <[email protected]>

2024-02-19 16:23:23

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH 07/10] s390/vdso: Use generic union vdso_data_store

On Mon, Feb 19, 2024 at 04:39:36PM +0100, Anna-Maria Behnsen wrote:
> There is already a generic union definition for vdso_data_store in vdso
> datapage header.
>
> Use this definition to prevent code duplication.
>
> Signed-off-by: Anna-Maria Behnsen <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: [email protected]
> ---
> arch/s390/kernel/vdso.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)

Acked-by: Heiko Carstens <[email protected]>

2024-02-20 00:27:14

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 00/10] vdso: Misc cleanups and prevent code duplication

On Mon, Feb 19, 2024 at 04:39:29PM +0100, Anna-Maria Behnsen wrote:
> Hi,
>
> the vdso related cleanup queue contains two parts:
>
> - Patch 1-3: Misc cleanups related to a comment, a superfluous header
> include and ifdeffery
>
> - Patch 4-10: The union vdso_data_store is defined in seven
> architectures. Make this union available in a generic vdso
> header file to prevent code duplication and fix the
> architectures one by one to use the generic vdso_data_store.
>
> Thanks,
>
> Anna-Maria

I do love a good clean-up! Thanks for this, I looked through all the
patches and they seem correct to me; removed definitions are all
identical, and __page_aligned_data is kept where needed.

Reviewed-by: Kees Cook <[email protected]>

-Kees

--
Kees Cook

2024-02-20 01:13:31

by Guo Ren

[permalink] [raw]
Subject: Re: [PATCH 10/10] csky/vdso: Use generic union vdso_data_store

On Mon, Feb 19, 2024 at 11:40 PM Anna-Maria Behnsen
<[email protected]> wrote:
>
> There is already a generic union definition for vdso_data_store in vdso
> datapage header.
>
> Use this definition to prevent code duplication.
>
> Signed-off-by: Anna-Maria Behnsen <[email protected]>
> Cc: Guo Ren <[email protected]>
> Cc: [email protected]
> ---
> arch/csky/kernel/vdso.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/arch/csky/kernel/vdso.c b/arch/csky/kernel/vdso.c
> index e74a2504d331..2ca886e4a458 100644
> --- a/arch/csky/kernel/vdso.c
> +++ b/arch/csky/kernel/vdso.c
> @@ -15,14 +15,8 @@ extern char vdso_start[], vdso_end[];
> static unsigned int vdso_pages;
> static struct page **vdso_pagelist;
>
> -/*
> - * The vDSO data page.
> - */
> -static union {
> - struct vdso_data data;
> - u8 page[PAGE_SIZE];
> -} vdso_data_store __page_aligned_data;
> -struct vdso_data *vdso_data = &vdso_data_store.data;
> +static union vdso_data_store vdso_data_store __page_aligned_data;
> +struct vdso_data *vdso_data = vdso_data_store.data;
>
> static int __init vdso_init(void)
> {
> --
> 2.39.2
>

Acked-by: Guo Ren <[email protected]>

--
Best Regards
Guo Ren

2024-02-20 06:46:52

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 06/10] riscv/vdso: Use generic union vdso_data_store

Hi Anna-Maria,

kernel test robot noticed the following build errors:

[auto build test ERROR on s390/features]
[also build test ERROR on kees/for-next/execve arm64/for-next/core linus/master v6.8-rc5 next-20240219]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Anna-Maria-Behnsen/vdso-helpers-Fix-grammar-in-comments/20240219-234251
base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
patch link: https://lore.kernel.org/r/20240219153939.75719-7-anna-maria%40linutronix.de
patch subject: [PATCH 06/10] riscv/vdso: Use generic union vdso_data_store
config: riscv-allnoconfig (https://download.01.org/0day-ci/archive/20240220/[email protected]/config)
compiler: riscv64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240220/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> arch/riscv/kernel/vdso.c:34:31: error: initialization of 'struct vdso_data *' from incompatible pointer type 'struct vdso_data (*)[2]' [-Werror=incompatible-pointer-types]
34 | struct vdso_data *vdso_data = &vdso_data_store.data;
| ^
cc1: some warnings being treated as errors


vim +34 arch/riscv/kernel/vdso.c

78a743cd82a35c Tong Tiangen 2021-09-01 32
2f3f68e0423414 Anna-Maria Behnsen 2024-02-19 33 static union vdso_data_store vdso_data_store __page_aligned_data;
ad5d1122b82fbd Vincent Chen 2020-06-09 @34 struct vdso_data *vdso_data = &vdso_data_store.data;
76d2a0493a17d4 Palmer Dabbelt 2017-07-10 35

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-02-20 09:00:32

by Anna-Maria Behnsen

[permalink] [raw]
Subject: [PATCH v1a] riscv/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: [email protected]
---
arch/riscv/kernel/vdso.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index 2cf76218a5bd..98315b98256d 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -30,14 +30,8 @@ enum rv_vdso_map {

#define VVAR_SIZE (VVAR_NR_PAGES << PAGE_SHIFT)

-/*
- * The vDSO data page.
- */
-static union {
- struct vdso_data data;
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
-struct vdso_data *vdso_data = &vdso_data_store.data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
+struct vdso_data *vdso_data = vdso_data_store.data;

struct __vdso_info {
const char *name;
--
2.39.2


2024-02-20 10:04:04

by Anna-Maria Behnsen

[permalink] [raw]
Subject: Re: [PATCH 00/10] vdso: Misc cleanups and prevent code duplication

Kees Cook <[email protected]> writes:

> On Mon, Feb 19, 2024 at 04:39:29PM +0100, Anna-Maria Behnsen wrote:
>> Hi,
>>
>> the vdso related cleanup queue contains two parts:
>>
>> - Patch 1-3: Misc cleanups related to a comment, a superfluous header
>> include and ifdeffery
>>
>> - Patch 4-10: The union vdso_data_store is defined in seven
>> architectures. Make this union available in a generic vdso
>> header file to prevent code duplication and fix the
>> architectures one by one to use the generic vdso_data_store.
>>
>> Thanks,
>>
>> Anna-Maria
>
> I do love a good clean-up! Thanks for this, I looked through all the
> patches and they seem correct to me;

Thank you! I had a mistake in there and already posted a new version for
this single patch - I forgot to update this patch before posting...

> removed definitions are all
> identical, and __page_aligned_data is kept where needed.
>
> Reviewed-by: Kees Cook <[email protected]>
>
> -Kees

Thanks,

Anna-Maria


2024-02-20 14:48:45

by Vincenzo Frascino

[permalink] [raw]
Subject: Re: [PATCH 00/10] vdso: Misc cleanups and prevent code duplication



On 19/02/2024 15:39, Anna-Maria Behnsen wrote:
> Hi,
>
> the vdso related cleanup queue contains two parts:
>
> - Patch 1-3: Misc cleanups related to a comment, a superfluous header
> include and ifdeffery
>
> - Patch 4-10: The union vdso_data_store is defined in seven
> architectures. Make this union available in a generic vdso
> header file to prevent code duplication and fix the
> architectures one by one to use the generic vdso_data_store.
>
> Thanks,
>
> Anna-Maria
>
>

Really good cleanup. Thank you for this.

Reviewed-by: Vincenzo Frascino <[email protected]>

> Anna-Maria Behnsen (10):
> vdso/helpers: Fix grammar in comments
> s390/vdso/data: Drop unnecessary header include
> csky/vdso: Remove superfluous ifdeffery
> vdso/arm: make union vdso_data_store available for all
> arm64/vdso: Use generic union vdso_data_store
> riscv/vdso: Use generic union vdso_data_store
> s390/vdso: Use generic union vdso_data_store
> loongarch/vdso: Use generic union vdso_data_store
> mips/vdso: Use generic union vdso_data_store
> csky/vdso: Use generic union vdso_data_store
>
> arch/arm/include/asm/elf.h | 1 -
> arch/arm/include/asm/vdso_datapage.h | 26 --------------------------
> arch/arm/kernel/asm-offsets.c | 4 +++-
> arch/arm/kernel/vdso.c | 4 ----
> arch/arm64/kernel/vdso.c | 5 +----
> arch/csky/include/asm/vdso.h | 5 -----
> arch/csky/kernel/vdso.c | 14 ++------------
> arch/loongarch/kernel/vdso.c | 6 ++----
> arch/mips/include/asm/vdso.h | 5 -----
> arch/mips/kernel/vdso.c | 2 +-
> arch/riscv/kernel/vdso.c | 8 +-------
> arch/s390/include/asm/vdso/data.h | 1 -
> arch/s390/kernel/vdso.c | 5 +----
> include/vdso/datapage.h | 10 ++++++++++
> include/vdso/helpers.h | 8 ++++----
> 15 files changed, 25 insertions(+), 79 deletions(-)
> delete mode 100644 arch/arm/include/asm/vdso_datapage.h
>

--
Regards,
Vincenzo

2024-02-20 20:04:37

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] csky/vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: 56145a0f84e8862aeb3b36d6e21349bb4dd64269
Gitweb: https://git.kernel.org/tip/56145a0f84e8862aeb3b36d6e21349bb4dd64269
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:39 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:01 +01:00

csky/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in the vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Guo Ren <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
arch/csky/kernel/vdso.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/csky/kernel/vdso.c b/arch/csky/kernel/vdso.c
index e74a250..2ca886e 100644
--- a/arch/csky/kernel/vdso.c
+++ b/arch/csky/kernel/vdso.c
@@ -15,14 +15,8 @@ extern char vdso_start[], vdso_end[];
static unsigned int vdso_pages;
static struct page **vdso_pagelist;

-/*
- * The vDSO data page.
- */
-static union {
- struct vdso_data data;
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
-struct vdso_data *vdso_data = &vdso_data_store.data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
+struct vdso_data *vdso_data = vdso_data_store.data;

static int __init vdso_init(void)
{

2024-02-20 20:04:40

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] MIPS: vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: d697a9997a0dfd1fcb26144f383c38e371b191b0
Gitweb: https://git.kernel.org/tip/d697a9997a0dfd1fcb26144f383c38e371b191b0
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:38 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:01 +01:00

MIPS: vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in the vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/mips/include/asm/vdso.h | 5 -----
arch/mips/kernel/vdso.c | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/mips/include/asm/vdso.h b/arch/mips/include/asm/vdso.h
index cc7b516..afb03d4 100644
--- a/arch/mips/include/asm/vdso.h
+++ b/arch/mips/include/asm/vdso.h
@@ -50,9 +50,4 @@ extern struct mips_vdso_image vdso_image_o32;
extern struct mips_vdso_image vdso_image_n32;
#endif

-union mips_vdso_data {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-};
-
#endif /* __ASM_VDSO_H */
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index f6d40e4..dda36fa 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -24,7 +24,7 @@
#include <vdso/vsyscall.h>

/* Kernel-provided data used by the VDSO. */
-static union mips_vdso_data mips_vdso_data __page_aligned_data;
+static union vdso_data_store mips_vdso_data __page_aligned_data;
struct vdso_data *vdso_data = mips_vdso_data.data;

/*

2024-02-20 20:05:20

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] riscv: vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: eba755314fa7bcb147193f51a44546697f3888f1
Gitweb: https://git.kernel.org/tip/eba755314fa7bcb147193f51a44546697f3888f1
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Tue, 20 Feb 2024 09:52:12 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

riscv: vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in the vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/riscv/kernel/vdso.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c
index 2cf7621..98315b9 100644
--- a/arch/riscv/kernel/vdso.c
+++ b/arch/riscv/kernel/vdso.c
@@ -30,14 +30,8 @@ enum rv_vdso_map {

#define VVAR_SIZE (VVAR_NR_PAGES << PAGE_SHIFT)

-/*
- * The vDSO data page.
- */
-static union {
- struct vdso_data data;
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
-struct vdso_data *vdso_data = &vdso_data_store.data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
+struct vdso_data *vdso_data = vdso_data_store.data;

struct __vdso_info {
const char *name;

2024-02-20 20:05:21

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] s390/vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: cb3444cfdb48b7ee7d208d19c97a29dd8252d884
Gitweb: https://git.kernel.org/tip/cb3444cfdb48b7ee7d208d19c97a29dd8252d884
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:36 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

s390/vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in the vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Heiko Carstens <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/s390/kernel/vdso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index bbaefd8..a45b3a4 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -25,10 +25,7 @@ extern char vdso32_start[], vdso32_end[];

static struct vm_special_mapping vvar_mapping;

-static union {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
+static union vdso_data_store vdso_data_store __page_aligned_data;

struct vdso_data *vdso_data = vdso_data_store.data;


2024-02-20 20:05:26

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] arm64: vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: d0fba04847ae1dc7015a2e87d5e4ae1111f7744e
Gitweb: https://git.kernel.org/tip/d0fba04847ae1dc7015a2e87d5e4ae1111f7744e
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:34 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

arm64: vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/arm64/kernel/vdso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 5562daf..89b6e78 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -69,10 +69,7 @@ static struct vdso_abi_info vdso_info[] __ro_after_init = {
/*
* The vDSO data page.
*/
-static union {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-} vdso_data_store __page_aligned_data;
+static union vdso_data_store vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = vdso_data_store.data;

static int vdso_mremap(const struct vm_special_mapping *sm,

2024-02-20 20:05:42

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] vdso/ARM: Make union vdso_data_store available for all architectures

The following commit has been merged into the timers/core branch of tip:

Commit-ID: a0d2fcd62ac2d3749ff48e30635fe8ea184f0a97
Gitweb: https://git.kernel.org/tip/a0d2fcd62ac2d3749ff48e30635fe8ea184f0a97
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:33 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

vdso/ARM: Make union vdso_data_store available for all architectures

The vDSO data page "union vdso_data_store" is defined in an ARM specific
header file and also defined in several other places.

Move the definition from the ARM header file into the generic vdso datapage
header to make it also usable for others and to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/arm/include/asm/elf.h | 1 -
arch/arm/include/asm/vdso_datapage.h | 26 --------------------------
arch/arm/kernel/asm-offsets.c | 4 +++-
arch/arm/kernel/vdso.c | 4 ----
include/vdso/datapage.h | 10 ++++++++++
5 files changed, 13 insertions(+), 32 deletions(-)
delete mode 100644 arch/arm/include/asm/vdso_datapage.h

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index d681016..9f21e17 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -4,7 +4,6 @@

#include <asm/auxvec.h>
#include <asm/hwcap.h>
-#include <asm/vdso_datapage.h>

/*
* ELF register definitions..
diff --git a/arch/arm/include/asm/vdso_datapage.h b/arch/arm/include/asm/vdso_datapage.h
deleted file mode 100644
index bef68f5..0000000
--- a/arch/arm/include/asm/vdso_datapage.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Adapted from arm64 version.
- *
- * Copyright (C) 2012 ARM Limited
- */
-#ifndef __ASM_VDSO_DATAPAGE_H
-#define __ASM_VDSO_DATAPAGE_H
-
-#ifdef __KERNEL__
-
-#ifndef __ASSEMBLY__
-
-#include <vdso/datapage.h>
-#include <asm/page.h>
-
-union vdso_data_store {
- struct vdso_data data[CS_BASES];
- u8 page[PAGE_SIZE];
-};
-
-#endif /* !__ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif /* __ASM_VDSO_DATAPAGE_H */
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 219cbc7..4915662 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -21,10 +21,12 @@
#include <asm/mpu.h>
#include <asm/procinfo.h>
#include <asm/suspend.h>
-#include <asm/vdso_datapage.h>
#include <asm/hardware/cache-l2x0.h>
#include <linux/kbuild.h>
#include <linux/arm-smccc.h>
+
+#include <vdso/datapage.h>
+
#include "signal.h"

/*
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index f297d66..d499ad4 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -21,7 +21,6 @@
#include <asm/cacheflush.h>
#include <asm/page.h>
#include <asm/vdso.h>
-#include <asm/vdso_datapage.h>
#include <clocksource/arm_arch_timer.h>
#include <vdso/helpers.h>
#include <vdso/vsyscall.h>
@@ -35,9 +34,6 @@ extern char vdso_start[], vdso_end[];
/* Total number of pages needed for the data and text portions of the VDSO. */
unsigned int vdso_total_pages __ro_after_init;

-/*
- * The VDSO data page.
- */
static union vdso_data_store vdso_data_store __page_aligned_data;
struct vdso_data *vdso_data = vdso_data_store.data;

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 73eb622..7ba4437 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -19,6 +19,8 @@
#include <vdso/time32.h>
#include <vdso/time64.h>

+#include <asm/page.h>
+
#ifdef CONFIG_ARCH_HAS_VDSO_DATA
#include <asm/vdso/data.h>
#else
@@ -121,6 +123,14 @@ struct vdso_data {
extern struct vdso_data _vdso_data[CS_BASES] __attribute__((visibility("hidden")));
extern struct vdso_data _timens_data[CS_BASES] __attribute__((visibility("hidden")));

+/**
+ * union vdso_data_store - Generic vDSO data page
+ */
+union vdso_data_store {
+ struct vdso_data data[CS_BASES];
+ u8 page[PAGE_SIZE];
+};
+
/*
* The generic vDSO implementation requires that gettimeofday.h
* provides:

2024-02-20 20:06:06

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] s390/vdso/data: Drop unnecessary header include

The following commit has been merged into the timers/core branch of tip:

Commit-ID: 3ebacc96f8862eb26f8a6568d91bda8ecff19879
Gitweb: https://git.kernel.org/tip/3ebacc96f8862eb26f8a6568d91bda8ecff19879
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:31 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

s390/vdso/data: Drop unnecessary header include

vdso/datapage.h includes the architecture specific vdso/data.h header
file. So there is no need to do it also the other way round and including
the generic vdso/datapage.h header file inside the architecture specific
data.h header file.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Heiko Carstens <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/s390/include/asm/vdso/data.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/arch/s390/include/asm/vdso/data.h b/arch/s390/include/asm/vdso/data.h
index 73ee891..0e2b40e 100644
--- a/arch/s390/include/asm/vdso/data.h
+++ b/arch/s390/include/asm/vdso/data.h
@@ -3,7 +3,6 @@
#define __S390_ASM_VDSO_DATA_H

#include <linux/types.h>
-#include <vdso/datapage.h>

struct arch_vdso_data {
__s64 tod_steering_delta;

2024-02-20 20:06:25

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] vdso/helpers: Fix grammar in comments

The following commit has been merged into the timers/core branch of tip:

Commit-ID: eeb9f5c2dcec90009d7cf12e780e7f9631993fc5
Gitweb: https://git.kernel.org/tip/eeb9f5c2dcec90009d7cf12e780e7f9631993fc5
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:30 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

vdso/helpers: Fix grammar in comments

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
include/vdso/helpers.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h
index 9a2af9f..7350114 100644
--- a/include/vdso/helpers.h
+++ b/include/vdso/helpers.h
@@ -30,9 +30,9 @@ static __always_inline u32 vdso_read_retry(const struct vdso_data *vd,
static __always_inline void vdso_write_begin(struct vdso_data *vd)
{
/*
- * WRITE_ONCE it is required otherwise the compiler can validly tear
+ * WRITE_ONCE() is required otherwise the compiler can validly tear
* updates to vd[x].seq and it is possible that the value seen by the
- * reader it is inconsistent.
+ * reader is inconsistent.
*/
WRITE_ONCE(vd[CS_HRES_COARSE].seq, vd[CS_HRES_COARSE].seq + 1);
WRITE_ONCE(vd[CS_RAW].seq, vd[CS_RAW].seq + 1);
@@ -43,9 +43,9 @@ static __always_inline void vdso_write_end(struct vdso_data *vd)
{
smp_wmb();
/*
- * WRITE_ONCE it is required otherwise the compiler can validly tear
+ * WRITE_ONCE() is required otherwise the compiler can validly tear
* updates to vd[x].seq and it is possible that the value seen by the
- * reader it is inconsistent.
+ * reader is inconsistent.
*/
WRITE_ONCE(vd[CS_HRES_COARSE].seq, vd[CS_HRES_COARSE].seq + 1);
WRITE_ONCE(vd[CS_RAW].seq, vd[CS_RAW].seq + 1);

2024-02-20 20:07:05

by tip-bot2 for Tony Luck

[permalink] [raw]
Subject: [tip: timers/core] LoongArch: vdso: Use generic union vdso_data_store

The following commit has been merged into the timers/core branch of tip:

Commit-ID: 8d87d2cd1d0136452d2afcd143e511ccad49018f
Gitweb: https://git.kernel.org/tip/8d87d2cd1d0136452d2afcd143e511ccad49018f
Author: Anna-Maria Behnsen <[email protected]>
AuthorDate: Mon, 19 Feb 2024 16:39:37 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 20 Feb 2024 20:56:00 +01:00

LoongArch: vdso: Use generic union vdso_data_store

There is already a generic union definition for vdso_data_store in vdso
datapage header.

Use this definition to prevent code duplication.

Signed-off-by: Anna-Maria Behnsen <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Vincenzo Frascino <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
arch/loongarch/kernel/vdso.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
index 14941e4..90dfccb 100644
--- a/arch/loongarch/kernel/vdso.c
+++ b/arch/loongarch/kernel/vdso.c
@@ -21,15 +21,13 @@
#include <asm/vdso.h>
#include <vdso/helpers.h>
#include <vdso/vsyscall.h>
+#include <vdso/datapage.h>
#include <generated/vdso-offsets.h>

extern char vdso_start[], vdso_end[];

/* Kernel-provided data used by the VDSO. */
-static union {
- u8 page[PAGE_SIZE];
- struct vdso_data data[CS_BASES];
-} generic_vdso_data __page_aligned_data;
+static union vdso_data_store generic_vdso_data __page_aligned_data;

static union {
u8 page[LOONGARCH_VDSO_DATA_SIZE];

2024-02-22 15:44:43

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH 05/10] arm64/vdso: Use generic union vdso_data_store

On Mon, Feb 19, 2024 at 04:39:34PM +0100, Anna-Maria Behnsen wrote:
> There is already a generic union definition for vdso_data_store in vdso
> datapage header.
>
> Use this definition to prevent code duplication.
>
> Signed-off-by: Anna-Maria Behnsen <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: [email protected]
> ---
> arch/arm64/kernel/vdso.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index 5562daf38a22..89b6e7840002 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -69,10 +69,7 @@ static struct vdso_abi_info vdso_info[] __ro_after_init = {
> /*
> * The vDSO data page.
> */
> -static union {
> - struct vdso_data data[CS_BASES];
> - u8 page[PAGE_SIZE];
> -} vdso_data_store __page_aligned_data;
> +static union vdso_data_store vdso_data_store __page_aligned_data;
> struct vdso_data *vdso_data = vdso_data_store.data;
>
> static int vdso_mremap(const struct vm_special_mapping *sm,
> --
> 2.39.2

Acked-by: Will Deacon <[email protected]>

Will