Skip to content

Commit 1184674

Browse files
t-8chKAGA-KOKO
authored andcommitted
powerpc: Split systemcfg data out of vdso data page
The systemcfg data only has minimal overlap with the vdso data. Splitting the two avoids mapping the implementation-defined vdso data into /proc/ppc64/systemcfg. It is also a preparation for the standardization of vdso data storage. The only field actually used by both systemcfg and vdso is tb_ticks_per_sec and it is only changed once during time_init(). Initialize it in both structures there. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20241010-vdso-generic-base-v1-26-b64f0842d512@linutronix.de
1 parent c22c06b commit 1184674

File tree

8 files changed

+48
-54
lines changed

8 files changed

+48
-54
lines changed

arch/powerpc/include/asm/vdso_datapage.h

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,6 @@
1010
*/
1111

1212

13-
/*
14-
* Note about this structure:
15-
*
16-
* This structure was historically called systemcfg and exposed to
17-
* userland via /proc/ppc64/systemcfg. Unfortunately, this became an
18-
* ABI issue as some proprietary software started relying on being able
19-
* to mmap() it, thus we have to keep the base layout at least for a
20-
* few kernel versions.
21-
*
22-
* However, since ppc32 doesn't suffer from this backward handicap,
23-
* a simpler version of the data structure is used there with only the
24-
* fields actually used by the vDSO.
25-
*
26-
*/
27-
2813
/*
2914
* If the major version changes we are incompatible.
3015
* Minor version changes are a hint.
@@ -40,13 +25,9 @@
4025

4126
#define SYSCALL_MAP_SIZE ((NR_syscalls + 31) / 32)
4227

43-
/*
44-
* So here is the ppc64 backward compatible version
45-
*/
46-
4728
#ifdef CONFIG_PPC64
4829

49-
struct vdso_arch_data {
30+
struct systemcfg {
5031
__u8 eye_catcher[16]; /* Eyecatcher: SYSTEMCFG:PPC64 0x00 */
5132
struct { /* Systemcfg version numbers */
5233
__u32 major; /* Major number 0x10 */
@@ -71,10 +52,12 @@ struct vdso_arch_data {
7152
__u32 dcache_line_size; /* L1 d-cache line size 0x64 */
7253
__u32 icache_size; /* L1 i-cache size 0x68 */
7354
__u32 icache_line_size; /* L1 i-cache line size 0x6C */
55+
};
7456

75-
/* those additional ones don't have to be located anywhere
76-
* special as they were not part of the original systemcfg
77-
*/
57+
extern struct systemcfg *systemcfg;
58+
59+
struct vdso_arch_data {
60+
__u64 tb_ticks_per_sec; /* Timebase tics / sec */
7861
__u32 dcache_block_size; /* L1 d-cache block size */
7962
__u32 icache_block_size; /* L1 i-cache block size */
8063
__u32 dcache_log_block_size; /* L1 d-cache log block size */
@@ -88,9 +71,6 @@ struct vdso_arch_data {
8871

8972
#else /* CONFIG_PPC64 */
9073

91-
/*
92-
* And here is the simpler 32 bits version
93-
*/
9474
struct vdso_arch_data {
9575
__u64 tb_ticks_per_sec; /* Timebase tics / sec */
9676
__u32 syscall_map[SYSCALL_MAP_SIZE]; /* Map of syscalls */

arch/powerpc/kernel/proc_powerpc.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <linux/init.h>
7+
#include <linux/memblock.h>
78
#include <linux/mm.h>
89
#include <linux/proc_fs.h>
910
#include <linux/kernel.h>
@@ -44,13 +45,35 @@ static const struct proc_ops page_map_proc_ops = {
4445
.proc_mmap = page_map_mmap,
4546
};
4647

48+
static union {
49+
struct systemcfg data;
50+
u8 page[PAGE_SIZE];
51+
} systemcfg_data_store __page_aligned_data;
52+
struct systemcfg *systemcfg = &systemcfg_data_store.data;
4753

4854
static int __init proc_ppc64_init(void)
4955
{
5056
struct proc_dir_entry *pde;
5157

58+
strcpy((char *)systemcfg->eye_catcher, "SYSTEMCFG:PPC64");
59+
systemcfg->version.major = SYSTEMCFG_MAJOR;
60+
systemcfg->version.minor = SYSTEMCFG_MINOR;
61+
systemcfg->processor = mfspr(SPRN_PVR);
62+
/*
63+
* Fake the old platform number for pSeries and add
64+
* in LPAR bit if necessary
65+
*/
66+
systemcfg->platform = 0x100;
67+
if (firmware_has_feature(FW_FEATURE_LPAR))
68+
systemcfg->platform |= 1;
69+
systemcfg->physicalMemorySize = memblock_phys_mem_size();
70+
systemcfg->dcache_size = ppc64_caches.l1d.size;
71+
systemcfg->dcache_line_size = ppc64_caches.l1d.line_size;
72+
systemcfg->icache_size = ppc64_caches.l1i.size;
73+
systemcfg->icache_line_size = ppc64_caches.l1i.line_size;
74+
5275
pde = proc_create_data("powerpc/systemcfg", S_IFREG | 0444, NULL,
53-
&page_map_proc_ops, vdso_data);
76+
&page_map_proc_ops, systemcfg);
5477
if (!pde)
5578
return 1;
5679
proc_set_size(pde, PAGE_SIZE);

arch/powerpc/kernel/setup-common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ void __init smp_setup_cpu_maps(void)
560560
out:
561561
of_node_put(dn);
562562
}
563-
vdso_data->processorCount = num_present_cpus();
563+
#endif
564+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
565+
systemcfg->processorCount = num_present_cpus();
564566
#endif /* CONFIG_PPC64 */
565567

566568
/* Initialize CPU <=> thread mapping/

arch/powerpc/kernel/smp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,8 @@ int generic_cpu_disable(void)
11861186
return -EBUSY;
11871187

11881188
set_cpu_online(cpu, false);
1189-
#ifdef CONFIG_PPC64
1190-
vdso_data->processorCount--;
1189+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
1190+
systemcfg->processorCount--;
11911191
#endif
11921192
/* Update affinity of all IRQs previously aimed at this CPU */
11931193
irq_migrate_all_off_this_cpu();
@@ -1642,10 +1642,12 @@ void start_secondary(void *unused)
16421642

16431643
secondary_cpu_time_init();
16441644

1645-
#ifdef CONFIG_PPC64
1645+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
16461646
if (system_state == SYSTEM_RUNNING)
1647-
vdso_data->processorCount++;
1647+
systemcfg->processorCount++;
1648+
#endif
16481649

1650+
#ifdef CONFIG_PPC64
16491651
vdso_getcpu_init();
16501652
#endif
16511653
set_numa_node(numa_cpu_lookup_table[cpu]);

arch/powerpc/kernel/time.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,9 @@ void __init time_init(void)
950950
}
951951

952952
vdso_data->tb_ticks_per_sec = tb_ticks_per_sec;
953+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
954+
systemcfg->tb_ticks_per_sec = tb_ticks_per_sec;
955+
#endif
953956

954957
/* initialise and enable the large decrementer (if we have one) */
955958
set_decrementer_max();

arch/powerpc/kernel/vdso.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/user.h>
1717
#include <linux/elf.h>
1818
#include <linux/security.h>
19-
#include <linux/memblock.h>
2019
#include <linux/syscalls.h>
2120
#include <linux/time_namespace.h>
2221
#include <vdso/datapage.h>
@@ -349,25 +348,6 @@ static struct page ** __init vdso_setup_pages(void *start, void *end)
349348
static int __init vdso_init(void)
350349
{
351350
#ifdef CONFIG_PPC64
352-
/*
353-
* Fill up the "systemcfg" stuff for backward compatibility
354-
*/
355-
strcpy((char *)vdso_data->eye_catcher, "SYSTEMCFG:PPC64");
356-
vdso_data->version.major = SYSTEMCFG_MAJOR;
357-
vdso_data->version.minor = SYSTEMCFG_MINOR;
358-
vdso_data->processor = mfspr(SPRN_PVR);
359-
/*
360-
* Fake the old platform number for pSeries and add
361-
* in LPAR bit if necessary
362-
*/
363-
vdso_data->platform = 0x100;
364-
if (firmware_has_feature(FW_FEATURE_LPAR))
365-
vdso_data->platform |= 1;
366-
vdso_data->physicalMemorySize = memblock_phys_mem_size();
367-
vdso_data->dcache_size = ppc64_caches.l1d.size;
368-
vdso_data->dcache_line_size = ppc64_caches.l1d.line_size;
369-
vdso_data->icache_size = ppc64_caches.l1i.size;
370-
vdso_data->icache_line_size = ppc64_caches.l1i.line_size;
371351
vdso_data->dcache_block_size = ppc64_caches.l1d.block_size;
372352
vdso_data->icache_block_size = ppc64_caches.l1i.block_size;
373353
vdso_data->dcache_log_block_size = ppc64_caches.l1d.log_block_size;

arch/powerpc/platforms/powernv/smp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ static int pnv_smp_cpu_disable(void)
136136
* the generic fixup_irqs. --BenH.
137137
*/
138138
set_cpu_online(cpu, false);
139-
vdso_data->processorCount--;
139+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
140+
systemcfg->processorCount--;
141+
#endif
140142
if (cpu == boot_cpuid)
141143
boot_cpuid = cpumask_any(cpu_online_mask);
142144
if (xive_enabled())

arch/powerpc/platforms/pseries/hotplug-cpu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ static int pseries_cpu_disable(void)
8383
int cpu = smp_processor_id();
8484

8585
set_cpu_online(cpu, false);
86-
vdso_data->processorCount--;
86+
#ifdef CONFIG_PPC64_PROC_SYSTEMCFG
87+
systemcfg->processorCount--;
88+
#endif
8789

8890
/*fix boot_cpuid here*/
8991
if (cpu == boot_cpuid)

0 commit comments

Comments
 (0)