Skip to content

Commit 0f5d752

Browse files
committed
Merge tag 's390-5.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Heiko Carstens: - Disable -Warray-bounds warning for gcc12, since the only known way to workaround false positive warnings on lowcore accesses would result in worse code on fast paths. - Avoid lockdep_assert_held() warning in kvm vm memop code. - Reduce overhead within gmap_rmap code to get rid of long latencies when e.g. shutting down 2nd level guests. * tag 's390-5.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: KVM: s390: vsie/gmap: reduce gmap_rmap overhead KVM: s390: Fix lockdep issue in vm memop s390: disable -Warray-bounds
2 parents 905a653 + a06afe8 commit 0f5d752

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

arch/s390/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
3030
KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
3131
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
3232
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
33+
34+
ifdef CONFIG_CC_IS_GCC
35+
ifeq ($(call cc-ifversion, -ge, 1200, y), y)
36+
ifeq ($(call cc-ifversion, -lt, 1300, y), y)
37+
KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
38+
KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, array-bounds)
39+
endif
40+
endif
41+
endif
42+
3343
UTS_MACHINE := s390x
3444
STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
3545
CHECKFLAGS += -D__s390__ -D__s390x__

arch/s390/kvm/kvm-s390.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,16 @@ static int kvm_s390_vm_mem_op(struct kvm *kvm, struct kvm_s390_mem_op *mop)
23842384
return -EINVAL;
23852385
if (mop->size > MEM_OP_MAX_SIZE)
23862386
return -E2BIG;
2387-
if (kvm_s390_pv_is_protected(kvm))
2387+
/*
2388+
* This is technically a heuristic only, if the kvm->lock is not
2389+
* taken, it is not guaranteed that the vm is/remains non-protected.
2390+
* This is ok from a kernel perspective, wrongdoing is detected
2391+
* on the access, -EFAULT is returned and the vm may crash the
2392+
* next time it accesses the memory in question.
2393+
* There is no sane usecase to do switching and a memop on two
2394+
* different CPUs at the same time.
2395+
*/
2396+
if (kvm_s390_pv_get_handle(kvm))
23882397
return -EINVAL;
23892398
if (mop->flags & KVM_S390_MEMOP_F_SKEY_PROTECTION) {
23902399
if (access_key_invalid(mop->key))

arch/s390/mm/gmap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,13 +1183,20 @@ EXPORT_SYMBOL_GPL(gmap_read_table);
11831183
static inline void gmap_insert_rmap(struct gmap *sg, unsigned long vmaddr,
11841184
struct gmap_rmap *rmap)
11851185
{
1186+
struct gmap_rmap *temp;
11861187
void __rcu **slot;
11871188

11881189
BUG_ON(!gmap_is_shadow(sg));
11891190
slot = radix_tree_lookup_slot(&sg->host_to_rmap, vmaddr >> PAGE_SHIFT);
11901191
if (slot) {
11911192
rmap->next = radix_tree_deref_slot_protected(slot,
11921193
&sg->guest_table_lock);
1194+
for (temp = rmap->next; temp; temp = temp->next) {
1195+
if (temp->raddr == rmap->raddr) {
1196+
kfree(rmap);
1197+
return;
1198+
}
1199+
}
11931200
radix_tree_replace_slot(&sg->host_to_rmap, slot, rmap);
11941201
} else {
11951202
rmap->next = NULL;

0 commit comments

Comments
 (0)