Skip to content

Commit 81d5598

Browse files
committed
Merge tag 's390-5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Vasily Gorbik: - Add support for KASAN_VMALLOC feature. - Remove the last user of problematic diag 0x44 call. - Adjust sampling interval and avoid sample data block overflow condition on pressure in perf code. - Prefer EOPNOTSUPP over ENOTSUPP and comments fixes. * tag 's390-5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/kasan: add KASAN_VMALLOC support s390: remove last diag 0x44 caller s390/uv: use EOPNOTSUPP instead of ENOTSUPP s390/cpum_sf: Avoid SBD overflow condition in irq handler s390/cpum_sf: Adjust sampling interval to avoid hitting sample limits s390/test_unwind: fix spelling mistake "reqister" -> "register" s390/spinlock: remove confusing comment in arch_spin_lock_wait
2 parents f791ede + 3e39ce2 commit 81d5598

File tree

9 files changed

+80
-47
lines changed

9 files changed

+80
-47
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ config S390
124124
select HAVE_ARCH_JUMP_LABEL
125125
select HAVE_ARCH_JUMP_LABEL_RELATIVE
126126
select HAVE_ARCH_KASAN
127+
select HAVE_ARCH_KASAN_VMALLOC
127128
select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
128129
select HAVE_ARCH_SECCOMP_FILTER
129130
select HAVE_ARCH_SOFT_DIRTY

arch/s390/include/asm/setup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define MACHINE_FLAG_DIAG9C BIT(3)
2828
#define MACHINE_FLAG_ESOP BIT(4)
2929
#define MACHINE_FLAG_IDTE BIT(5)
30-
#define MACHINE_FLAG_DIAG44 BIT(6)
3130
#define MACHINE_FLAG_EDAT1 BIT(7)
3231
#define MACHINE_FLAG_EDAT2 BIT(8)
3332
#define MACHINE_FLAG_TOPOLOGY BIT(10)
@@ -94,7 +93,6 @@ extern unsigned long __swsusp_reset_dma;
9493
#define MACHINE_HAS_DIAG9C (S390_lowcore.machine_flags & MACHINE_FLAG_DIAG9C)
9594
#define MACHINE_HAS_ESOP (S390_lowcore.machine_flags & MACHINE_FLAG_ESOP)
9695
#define MACHINE_HAS_IDTE (S390_lowcore.machine_flags & MACHINE_FLAG_IDTE)
97-
#define MACHINE_HAS_DIAG44 (S390_lowcore.machine_flags & MACHINE_FLAG_DIAG44)
9896
#define MACHINE_HAS_EDAT1 (S390_lowcore.machine_flags & MACHINE_FLAG_EDAT1)
9997
#define MACHINE_HAS_EDAT2 (S390_lowcore.machine_flags & MACHINE_FLAG_EDAT2)
10098
#define MACHINE_HAS_TOPOLOGY (S390_lowcore.machine_flags & MACHINE_FLAG_TOPOLOGY)

arch/s390/include/asm/uv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static inline int share(unsigned long addr, u16 cmd)
8686
};
8787

8888
if (!is_prot_virt_guest())
89-
return -ENOTSUPP;
89+
return -EOPNOTSUPP;
9090
/*
9191
* Sharing is page wise, if we encounter addresses that are
9292
* not page aligned, we assume something went wrong. If

arch/s390/kernel/early.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,6 @@ static __init void detect_diag9c(void)
204204
S390_lowcore.machine_flags |= MACHINE_FLAG_DIAG9C;
205205
}
206206

207-
static __init void detect_diag44(void)
208-
{
209-
int rc;
210-
211-
diag_stat_inc(DIAG_STAT_X044);
212-
asm volatile(
213-
" diag 0,0,0x44\n"
214-
"0: la %0,0\n"
215-
"1:\n"
216-
EX_TABLE(0b,1b)
217-
: "=d" (rc) : "0" (-EOPNOTSUPP) : "cc");
218-
if (!rc)
219-
S390_lowcore.machine_flags |= MACHINE_FLAG_DIAG44;
220-
}
221-
222207
static __init void detect_machine_facilities(void)
223208
{
224209
if (test_facility(8)) {
@@ -331,7 +316,6 @@ void __init startup_init(void)
331316
setup_arch_string();
332317
setup_boot_command_line();
333318
detect_diag9c();
334-
detect_diag44();
335319
detect_machine_facilities();
336320
save_vector_registers();
337321
setup_topology();

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,18 +1303,28 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all)
13031303
*/
13041304
if (flush_all && done)
13051305
break;
1306-
1307-
/* If an event overflow happened, discard samples by
1308-
* processing any remaining sample-data-blocks.
1309-
*/
1310-
if (event_overflow)
1311-
flush_all = 1;
13121306
}
13131307

13141308
/* Account sample overflows in the event hardware structure */
13151309
if (sampl_overflow)
13161310
OVERFLOW_REG(hwc) = DIV_ROUND_UP(OVERFLOW_REG(hwc) +
13171311
sampl_overflow, 1 + num_sdb);
1312+
1313+
/* Perf_event_overflow() and perf_event_account_interrupt() limit
1314+
* the interrupt rate to an upper limit. Roughly 1000 samples per
1315+
* task tick.
1316+
* Hitting this limit results in a large number
1317+
* of throttled REF_REPORT_THROTTLE entries and the samples
1318+
* are dropped.
1319+
* Slightly increase the interval to avoid hitting this limit.
1320+
*/
1321+
if (event_overflow) {
1322+
SAMPL_RATE(hwc) += DIV_ROUND_UP(SAMPL_RATE(hwc), 10);
1323+
debug_sprintf_event(sfdbg, 1, "%s: rate adjustment %ld\n",
1324+
__func__,
1325+
DIV_ROUND_UP(SAMPL_RATE(hwc), 10));
1326+
}
1327+
13181328
if (sampl_overflow || event_overflow)
13191329
debug_sprintf_event(sfdbg, 4, "%s: "
13201330
"overflows: sample %llu event %llu"

arch/s390/kernel/smp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,11 @@ EXPORT_SYMBOL(arch_vcpu_is_preempted);
413413

414414
void smp_yield_cpu(int cpu)
415415
{
416-
if (MACHINE_HAS_DIAG9C) {
417-
diag_stat_inc_norecursion(DIAG_STAT_X09C);
418-
asm volatile("diag %0,0,0x9c"
419-
: : "d" (pcpu_devices[cpu].address));
420-
} else if (MACHINE_HAS_DIAG44 && !smp_cpu_mtid) {
421-
diag_stat_inc_norecursion(DIAG_STAT_X044);
422-
asm volatile("diag 0,0,0x44");
423-
}
416+
if (!MACHINE_HAS_DIAG9C)
417+
return;
418+
diag_stat_inc_norecursion(DIAG_STAT_X09C);
419+
asm volatile("diag %0,0,0x9c"
420+
: : "d" (pcpu_devices[cpu].address));
424421
}
425422

426423
/*

arch/s390/lib/spinlock.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ static inline void arch_spin_lock_classic(arch_spinlock_t *lp)
242242

243243
void arch_spin_lock_wait(arch_spinlock_t *lp)
244244
{
245-
/* Use classic spinlocks + niai if the steal time is >= 10% */
246245
if (test_cpu_flag(CIF_DEDICATED_CPU))
247246
arch_spin_lock_queued(lp);
248247
else

arch/s390/lib/test_unwind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int test_unwind_irq(struct unwindme *u)
238238
{
239239
preempt_disable();
240240
if (register_external_irq(EXT_IRQ_CLK_COMP, unwindme_irq_handler)) {
241-
pr_info("Couldn't reqister external interrupt handler");
241+
pr_info("Couldn't register external interrupt handler");
242242
return -1;
243243
}
244244
u->task = current;

arch/s390/mm/kasan_init.c

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ static pte_t * __init kasan_early_pte_alloc(void)
8282
enum populate_mode {
8383
POPULATE_ONE2ONE,
8484
POPULATE_MAP,
85-
POPULATE_ZERO_SHADOW
85+
POPULATE_ZERO_SHADOW,
86+
POPULATE_SHALLOW
8687
};
8788
static void __init kasan_early_vmemmap_populate(unsigned long address,
8889
unsigned long end,
@@ -116,6 +117,12 @@ static void __init kasan_early_vmemmap_populate(unsigned long address,
116117
pgd_populate(&init_mm, pg_dir, p4_dir);
117118
}
118119

120+
if (IS_ENABLED(CONFIG_KASAN_S390_4_LEVEL_PAGING) &&
121+
mode == POPULATE_SHALLOW) {
122+
address = (address + P4D_SIZE) & P4D_MASK;
123+
continue;
124+
}
125+
119126
p4_dir = p4d_offset(pg_dir, address);
120127
if (p4d_none(*p4_dir)) {
121128
if (mode == POPULATE_ZERO_SHADOW &&
@@ -130,6 +137,12 @@ static void __init kasan_early_vmemmap_populate(unsigned long address,
130137
p4d_populate(&init_mm, p4_dir, pu_dir);
131138
}
132139

140+
if (!IS_ENABLED(CONFIG_KASAN_S390_4_LEVEL_PAGING) &&
141+
mode == POPULATE_SHALLOW) {
142+
address = (address + PUD_SIZE) & PUD_MASK;
143+
continue;
144+
}
145+
133146
pu_dir = pud_offset(p4_dir, address);
134147
if (pud_none(*pu_dir)) {
135148
if (mode == POPULATE_ZERO_SHADOW &&
@@ -195,6 +208,9 @@ static void __init kasan_early_vmemmap_populate(unsigned long address,
195208
page = kasan_early_shadow_page;
196209
pte_val(*pt_dir) = __pa(page) | pgt_prot_zero;
197210
break;
211+
case POPULATE_SHALLOW:
212+
/* should never happen */
213+
break;
198214
}
199215
}
200216
address += PAGE_SIZE;
@@ -313,22 +329,50 @@ void __init kasan_early_init(void)
313329
init_mm.pgd = early_pg_dir;
314330
/*
315331
* Current memory layout:
316-
* +- 0 -------------+ +- shadow start -+
317-
* | 1:1 ram mapping | /| 1/8 ram |
318-
* +- end of ram ----+ / +----------------+
319-
* | ... gap ... |/ | kasan |
320-
* +- shadow start --+ | zero |
321-
* | 1/8 addr space | | page |
322-
* +- shadow end -+ | mapping |
323-
* | ... gap ... |\ | (untracked) |
324-
* +- modules vaddr -+ \ +----------------+
325-
* | 2Gb | \| unmapped | allocated per module
326-
* +-----------------+ +- shadow end ---+
332+
* +- 0 -------------+ +- shadow start -+
333+
* | 1:1 ram mapping | /| 1/8 ram |
334+
* | | / | |
335+
* +- end of ram ----+ / +----------------+
336+
* | ... gap ... | / | |
337+
* | |/ | kasan |
338+
* +- shadow start --+ | zero |
339+
* | 1/8 addr space | | page |
340+
* +- shadow end -+ | mapping |
341+
* | ... gap ... |\ | (untracked) |
342+
* +- vmalloc area -+ \ | |
343+
* | vmalloc_size | \ | |
344+
* +- modules vaddr -+ \ +----------------+
345+
* | 2Gb | \| unmapped | allocated per module
346+
* +-----------------+ +- shadow end ---+
347+
*
348+
* Current memory layout (KASAN_VMALLOC):
349+
* +- 0 -------------+ +- shadow start -+
350+
* | 1:1 ram mapping | /| 1/8 ram |
351+
* | | / | |
352+
* +- end of ram ----+ / +----------------+
353+
* | ... gap ... | / | kasan |
354+
* | |/ | zero |
355+
* +- shadow start --+ | page |
356+
* | 1/8 addr space | | mapping |
357+
* +- shadow end -+ | (untracked) |
358+
* | ... gap ... |\ | |
359+
* +- vmalloc area -+ \ +- vmalloc area -+
360+
* | vmalloc_size | \ |shallow populate|
361+
* +- modules vaddr -+ \ +- modules area -+
362+
* | 2Gb | \|shallow populate|
363+
* +-----------------+ +- shadow end ---+
327364
*/
328365
/* populate kasan shadow (for identity mapping and zero page mapping) */
329366
kasan_early_vmemmap_populate(__sha(0), __sha(memsize), POPULATE_MAP);
330367
if (IS_ENABLED(CONFIG_MODULES))
331368
untracked_mem_end = vmax - MODULES_LEN;
369+
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
370+
untracked_mem_end = vmax - vmalloc_size - MODULES_LEN;
371+
/* shallowly populate kasan shadow for vmalloc and modules */
372+
kasan_early_vmemmap_populate(__sha(untracked_mem_end),
373+
__sha(vmax), POPULATE_SHALLOW);
374+
}
375+
/* populate kasan shadow for untracked memory */
332376
kasan_early_vmemmap_populate(__sha(max_physmem_end),
333377
__sha(untracked_mem_end),
334378
POPULATE_ZERO_SHADOW);

0 commit comments

Comments
 (0)