Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1048830imj; Wed, 13 Feb 2019 23:57:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IY7RogztHQyg6K0gNEbo4pSNuFeh6dkvIhNTHUaknheHTZinD8uNTVvpj9kuW5kGQJYc2ur X-Received: by 2002:aa7:8847:: with SMTP id k7mr2623173pfo.99.1550131021033; Wed, 13 Feb 2019 23:57:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550131021; cv=none; d=google.com; s=arc-20160816; b=nv3XvWeVZrCKKkIz2rmis4qJ91gGkbAtcs59jNy4TIhWc6PEu2GR9lStkURk6Em5JM R+NUyR5ciHb2NG7CrajBQ58Q2uaoSgsahVpaSp11yTqZbvZEXOOdXdzw1j8sBCPIG2cM H2eoNrVZvpm9S2ZJNehQJK90OLJsxkXLD24HA/umCJQnOQyH/E+b0lx50lvKGuaO3MqZ q9+1GYCkZH0KOxeSVIPkuYy+hT38o32MuBQm/uquay8jIH3HJEKl2lZsmPQaT6jdkgJg N0CuOr5akC45n2K7WulZ/+ArR9MeWrVeDDT35LY76rG446UVmUbnMF40KlLfjV2ksETS YwEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PBwmuj8m4c0n8UrSwGOnQ/s8tRXeamnIpv37Dw63Eg0=; b=Q14H8ZlnNob++NJG5JvuVnMpEpJqUL0uxshycoeNweGVKOv6yckds7mTG/lJ/rqBXD Lo+rUat0dxtlW7GbwMNLIJlIPrRaq0SXAtmw6qts9dgyWm6ya4wzkv8CTyXo3Q44Jk5e gymjmLKx2Cf0IBixil+kRm10ATjUNBrNSI6QZzSB35WjKVJ+TBqIewOwVdbPWLrwLbxD I75zM2sPy5cqZfQati628ujtBcy0l2SiWmomnYdvzzaP9skKay3LyP4kUBji/ECLZ6tI w94rpAMG1LxSUv8Q+XkF5UD3X+6U9GUTiifUkFYenwdpVVS/J2uYMjgs9wbd3B6TA9Zz bA3A== 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 j132si1811833pfc.84.2019.02.13.23.56.45; Wed, 13 Feb 2019 23:57:01 -0800 (PST) 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 S2394460AbfBMTfF (ORCPT + 99 others); Wed, 13 Feb 2019 14:35:05 -0500 Received: from mx0b-002e3701.pphosted.com ([148.163.143.35]:33790 "EHLO mx0b-002e3701.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394422AbfBMTez (ORCPT ); Wed, 13 Feb 2019 14:34:55 -0500 Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1DJLloA004850; Wed, 13 Feb 2019 19:34:39 GMT Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) by mx0b-002e3701.pphosted.com with ESMTP id 2qmrrvrb8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Feb 2019 19:34:39 +0000 Received: from sarge.linuxathome.me (unknown [16.99.162.65]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id BFE35CD; Wed, 13 Feb 2019 19:34:35 +0000 (UTC) From: Hedi Berriche To: linux-kernel@vger.kernel.org, Ard Biesheuvel , Thomas Gleixner , Bhupesh Sharma Cc: Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-efi@vger.kernel.org, x86@kernel.org, Russ Anderson , Mike Travis , Dimitri Sivanich , Steve Wahl , stable@vger.kernel.org Subject: [Patch v3 4/4] x86/platform/UV: use efi_runtime_lock to serialise BIOS calls Date: Wed, 13 Feb 2019 19:34:13 +0000 Message-Id: <20190213193413.25560-5-hedi.berriche@hpe.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213193413.25560-1-hedi.berriche@hpe.com> References: <20190213193413.25560-1-hedi.berriche@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-13_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=905 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902130132 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Calls into UV firmware must be protected against concurrency, expose the efi_runtime_lock to the UV platform, and use it to serialise UV BIOS calls. Cc: Russ Anderson Cc: Mike Travis Cc: Dimitri Sivanich Cc: Steve Wahl Cc: stable@vger.kernel.org # v4.9+ Signed-off-by: Hedi Berriche --- arch/x86/include/asm/uv/bios.h | 8 +++++++- arch/x86/platform/uv/bios_uv.c | 23 +++++++++++++++++++++-- drivers/firmware/efi/runtime-wrappers.c | 7 +++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/uv/bios.h b/arch/x86/include/asm/uv/bios.h index 8c6ac271b5b3..8cfccc3cbbf4 100644 --- a/arch/x86/include/asm/uv/bios.h +++ b/arch/x86/include/asm/uv/bios.h @@ -48,7 +48,8 @@ enum { BIOS_STATUS_SUCCESS = 0, BIOS_STATUS_UNIMPLEMENTED = -ENOSYS, BIOS_STATUS_EINVAL = -EINVAL, - BIOS_STATUS_UNAVAIL = -EBUSY + BIOS_STATUS_UNAVAIL = -EBUSY, + BIOS_STATUS_ABORT = -EINTR, }; /* Address map parameters */ @@ -162,4 +163,9 @@ extern long system_serial_number; extern struct kobject *sgi_uv_kobj; /* /sys/firmware/sgi_uv */ +/* + * EFI runtime lock; cf. firmware/efi/runtime-wrappers.c for details + */ +extern struct semaphore __efi_uv_runtime_lock; + #endif /* _ASM_X86_UV_BIOS_H */ diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c index 38a2e3431fc6..ef60d789c76e 100644 --- a/arch/x86/platform/uv/bios_uv.c +++ b/arch/x86/platform/uv/bios_uv.c @@ -29,7 +29,8 @@ struct uv_systab *uv_systab; -s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) +static s64 __uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, + u64 a4, u64 a5) { struct uv_systab *tab = uv_systab; s64 ret; @@ -51,6 +52,19 @@ s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) return ret; } + +s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) +{ + s64 ret; + + if (down_interruptible(&__efi_uv_runtime_lock)) + return BIOS_STATUS_ABORT; + + ret = __uv_bios_call(which, a1, a2, a3, a4, a5); + up(&__efi_uv_runtime_lock); + + return ret; +} EXPORT_SYMBOL_GPL(uv_bios_call); s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, @@ -59,10 +73,15 @@ s64 uv_bios_call_irqsave(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, unsigned long bios_flags; s64 ret; + if (down_interruptible(&__efi_uv_runtime_lock)) + return BIOS_STATUS_ABORT; + local_irq_save(bios_flags); - ret = uv_bios_call(which, a1, a2, a3, a4, a5); + ret = __uv_bios_call(which, a1, a2, a3, a4, a5); local_irq_restore(bios_flags); + up(&__efi_uv_runtime_lock); + return ret; } diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c index 8903b9ccfc2b..e2abfdb5cee6 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -146,6 +146,13 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call) */ static DEFINE_SEMAPHORE(efi_runtime_lock); +/* + * Expose the EFI runtime lock to the UV platform + */ +#ifdef CONFIG_X86_UV +extern struct semaphore __efi_uv_runtime_lock __alias(efi_runtime_lock); +#endif + /* * Calls the appropriate efi_runtime_service() with the appropriate * arguments. -- 2.20.1