Received: by 10.192.165.148 with SMTP id m20csp805916imm; Fri, 27 Apr 2018 07:49:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoUxBrb4dX+Vps6uhtJ0fDMqqMhEaW3zLLe12A9yXmXUI9Bj9UlRnrW/Xl8REiJ2ayeLPeP X-Received: by 10.98.21.73 with SMTP id 70mr2496702pfv.91.1524840558096; Fri, 27 Apr 2018 07:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840558; cv=none; d=google.com; s=arc-20160816; b=rjqfaIY+cBykQIWvavL4bzNnSUJipTRXdsbsx9qzLx4L4k9t7HGDXheqq1/o27PNU0 jkFGsLVwIM5c8cc+bpfmi+CglVunAz5y6F8ddOZLdWPbsPyh6lZxeHRNNhWsKlUqhFzT MS5eSJLzYa+4e5Hjg5ekGwonmXtyINI5aE2DoXfhXkr9NNW5VqxfoVivYyY73UlTLYTI coigZTgl1KUUkmp/9Tb9CyJ/AHtb0KCvmScg2bjhU2HWnHhLHcY7Zv62atgBoERnJVyD P0PrNZmawHpkHaVpLI9gSXMCosoX1gmUfmCdIXRh6T5fRmt0clGv+85IlriakHIBtVqk FIMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=8EWrbZ5CUq+uUf6Lg4NHz1YCBxJRZPvOIxOTD0JZqtY=; b=jlAzI/ZHHZnbcNrRman85ap2GQ0HD5rH+HMavRTwJhRWmtR5hrtxp1kWczGukGS3pa D3FNYJ3KrmRYHSV7H49UbQuXmHR64BuGiADaxgVBwZMpJs7D/G2ZxynQV46UJSoa593S xDRjXuz6EQgeHgK0mzaF0ax+2rsQfpeijJuQU7BtQYMEbyBMl5pc/C1yKcMXriEen4fI yKMfWOkuNsouCeCHBGt8pS4TUC5MF8yoqi9+PjBRAUg31HrPU8PB/hNXncnIUPqMvtST aD2/NmkhteGOHUR7dmI+PTQPUXbhnIA+TjuCN4I8oilx9AowlVOnqK3/0mR29Ql+1cEJ djpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16-v6si1300750pgv.596.2018.04.27.07.49.03; Fri, 27 Apr 2018 07:49:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934048AbeD0OHp (ORCPT + 99 others); Fri, 27 Apr 2018 10:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933869AbeD0OHm (ORCPT ); Fri, 27 Apr 2018 10:07:42 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22F02218CA; Fri, 27 Apr 2018 14:07:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22F02218CA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Schwidefsky , David Hildenbrand , Cornelia Huck Subject: [PATCH 4.14 47/80] s390/alternative: use a copy of the facility bit mask Date: Fri, 27 Apr 2018 15:58:40 +0200 Message-Id: <20180427135735.354589719@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Schwidefsky [ Upstream commit cf1489984641369611556bf00c48f945c77bcf02 ] To be able to switch off specific CPU alternatives with kernel parameters make a copy of the facility bit mask provided by STFLE and use the copy for the decision to apply an alternative. Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Greg Kroah-Hartman --- arch/s390/include/asm/facility.h | 18 ++++++++++++++++++ arch/s390/include/asm/lowcore.h | 3 ++- arch/s390/kernel/alternative.c | 3 ++- arch/s390/kernel/early.c | 3 +++ arch/s390/kernel/setup.c | 4 +++- arch/s390/kernel/smp.c | 4 +++- 6 files changed, 31 insertions(+), 4 deletions(-) --- a/arch/s390/include/asm/facility.h +++ b/arch/s390/include/asm/facility.h @@ -15,6 +15,24 @@ #define MAX_FACILITY_BIT (sizeof(((struct lowcore *)0)->stfle_fac_list) * 8) +static inline void __set_facility(unsigned long nr, void *facilities) +{ + unsigned char *ptr = (unsigned char *) facilities; + + if (nr >= MAX_FACILITY_BIT) + return; + ptr[nr >> 3] |= 0x80 >> (nr & 7); +} + +static inline void __clear_facility(unsigned long nr, void *facilities) +{ + unsigned char *ptr = (unsigned char *) facilities; + + if (nr >= MAX_FACILITY_BIT) + return; + ptr[nr >> 3] &= ~(0x80 >> (nr & 7)); +} + static inline int __test_facility(unsigned long nr, void *facilities) { unsigned char *ptr; --- a/arch/s390/include/asm/lowcore.h +++ b/arch/s390/include/asm/lowcore.h @@ -155,7 +155,8 @@ struct lowcore { __u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */ /* Extended facility list */ - __u64 stfle_fac_list[32]; /* 0x0f00 */ + __u64 stfle_fac_list[16]; /* 0x0f00 */ + __u64 alt_stfle_fac_list[16]; /* 0x0f80 */ __u8 pad_0x1000[0x11b0-0x1000]; /* 0x1000 */ /* Pointer to the machine check extended save area */ --- a/arch/s390/kernel/alternative.c +++ b/arch/s390/kernel/alternative.c @@ -74,7 +74,8 @@ static void __init_or_module __apply_alt instr = (u8 *)&a->instr_offset + a->instr_offset; replacement = (u8 *)&a->repl_offset + a->repl_offset; - if (!test_facility(a->facility)) + if (!__test_facility(a->facility, + S390_lowcore.alt_stfle_fac_list)) continue; if (unlikely(a->instrlen % 2 || a->replacementlen % 2)) { --- a/arch/s390/kernel/early.c +++ b/arch/s390/kernel/early.c @@ -329,6 +329,9 @@ static noinline __init void setup_facili { stfle(S390_lowcore.stfle_fac_list, ARRAY_SIZE(S390_lowcore.stfle_fac_list)); + memcpy(S390_lowcore.alt_stfle_fac_list, + S390_lowcore.stfle_fac_list, + sizeof(S390_lowcore.alt_stfle_fac_list)); } static __init void detect_diag9c(void) --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -339,7 +339,9 @@ static void __init setup_lowcore(void) lc->preempt_count = S390_lowcore.preempt_count; lc->stfl_fac_list = S390_lowcore.stfl_fac_list; memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, - MAX_FACILITY_BIT/8); + sizeof(lc->stfle_fac_list)); + memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list, + sizeof(lc->alt_stfle_fac_list)); if (MACHINE_HAS_VX || MACHINE_HAS_GS) { unsigned long bits, size; --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -282,7 +282,9 @@ static void pcpu_prepare_secondary(struc __ctl_store(lc->cregs_save_area, 0, 15); save_access_regs((unsigned int *) lc->access_regs_save_area); memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, - MAX_FACILITY_BIT/8); + sizeof(lc->stfle_fac_list)); + memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list, + sizeof(lc->alt_stfle_fac_list)); } static void pcpu_attach_task(struct pcpu *pcpu, struct task_struct *tsk)