Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2456089imj; Mon, 18 Feb 2019 06:21:45 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia9OlqtUNB/JqFnQi+f2qwaqQnw/X1np0rjeYdnUiktJvI+1tu1V+a2f2HG41NhOcHvUJ7v X-Received: by 2002:a63:295:: with SMTP id 143mr18452967pgc.362.1550499705794; Mon, 18 Feb 2019 06:21:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550499705; cv=none; d=google.com; s=arc-20160816; b=izy5SvOPkBPSfxpsn3KIHdBOJXsrgYDKgox8BTNL6uCq4t8SEE8nhG//Wat3M4xIjk 7yzI5vrlIz0E9YZtesRT/od1VrTh5oo36vj8Pg9Yv40atSMJALHPsWXUh8abVRk54uII lXsj/QAiJRLwPaE/dLJpVFWNLOBIwdtruoSknT3UlmY3a3mIcVPEInxCzKBVKmZIEfVA 5LcYJtE97h8XiQ9LG6259Uatk/GoIDQyKrkwQkCLBi4HK7OSsPaqeYoRGHXdqlJyGzKq AK19e2jANRB6qGlRy21zu8Vm+7Ki8jnQtwHVtPvQmKrHWw/Nc/W2qdy3/8z2yRyPTlmJ lX9Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pe3cSNhG5XdSytj+E7ROPegg2xcreax0mWgCmCwKugM=; b=cFpoGXCFqRVC85gSMfJFvOZIDAuiQbhnRO55dcysgbtJv2sx8cqjIFULRw34vdiyMV KLQZ5EFGOsYlLh1X2qJxGRGnLZSfYGzzRr21fw8s2kYXJ4Zw4ZJOqHZSBw0Q+FXk+cMq s92txLrAX9TdtWR9i+JSloXMnst2l2bIkLmh7kmtGnwWbmC2NRVwKpcVfeqzDHwjtba2 Lu6XA4KjD6zEsq8CQK27dWERhNhfotiNgbYLIBjJ36oEDk3Xp3x8dkZZ5JF2IswNxNkM S98WPX6yKjjrPd5SVb2to1ayg1lP51Fq7fJxBw3poFTRdrh9wuiRZiFfkWAd9jDYLCyZ FWSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DYSIfRBe; 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 c11si13205066pgj.255.2019.02.18.06.21.29; Mon, 18 Feb 2019 06:21:45 -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; dkim=pass header.i=@kernel.org header.s=default header.b=DYSIfRBe; 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 S2389794AbfBROHO (ORCPT + 99 others); Mon, 18 Feb 2019 09:07:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:50270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390058AbfBROHL (ORCPT ); Mon, 18 Feb 2019 09:07:11 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 A160521901; Mon, 18 Feb 2019 14:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498830; bh=5U4cZp7BRPY0MJtVYZ5pU9JBuLnacpTqVgR9ivrpCfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DYSIfRBeW0+HmRPn1HTqSSUYzbr+VLb4E2d0T9irBVZI9YPmQ8ElKZ/mRr0IGzvvk 2/SEI6eF6Hr0E60ol+WdL766xWVtcJX92dOHae+wuG/nhs8AwnbxShn11XtUY3XRIp 1bOQMxmayqhK5nhpm7hK8H1hIB39ZdeeNCR9yeVg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hedi Berriche , Borislav Petkov , Ard Biesheuvel , Russ Anderson , Dimitri Sivanich , Mike Travis , Andy Shevchenko , Bhupesh Sharma , Darren Hart , "H. Peter Anvin" , Ingo Molnar , linux-efi , platform-driver-x86@vger.kernel.org, Steve Wahl , Thomas Gleixner , x86-ml Subject: [PATCH 4.4 135/143] x86/platform/UV: Use efi_runtime_lock to serialise BIOS calls Date: Mon, 18 Feb 2019 14:44:23 +0100 Message-Id: <20190218133533.912603392@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hedi Berriche commit f331e766c4be33f4338574f3c9f7f77e98ab4571 upstream. 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. Signed-off-by: Hedi Berriche Signed-off-by: Borislav Petkov Reviewed-by: Ard Biesheuvel Reviewed-by: Russ Anderson Reviewed-by: Dimitri Sivanich Reviewed-by: Mike Travis Cc: Andy Shevchenko Cc: Bhupesh Sharma Cc: Darren Hart Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: linux-efi Cc: platform-driver-x86@vger.kernel.org Cc: stable@vger.kernel.org # v4.9+ Cc: Steve Wahl Cc: Thomas Gleixner Cc: x86-ml Link: https://lkml.kernel.org/r/20190213193413.25560-5-hedi.berriche@hpe.com Signed-off-by: Greg Kroah-Hartman --- 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(-) --- 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, }; /* @@ -111,4 +112,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 */ --- a/arch/x86/platform/uv/bios_uv.c +++ b/arch/x86/platform/uv/bios_uv.c @@ -28,7 +28,8 @@ static 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; @@ -43,6 +44,19 @@ s64 uv_bios_call(enum uv_bios_cmd which, a1, a2, a3, a4, 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, @@ -51,10 +65,15 @@ s64 uv_bios_call_irqsave(enum uv_bios_cm 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; } --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -88,6 +88,13 @@ static DEFINE_SPINLOCK(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 + +/* * As per commit ef68c8f87ed1 ("x86: Serialize EFI time accesses on rtc_lock"), * the EFI specification requires that callers of the time related runtime * functions serialize with other CMOS accesses in the kernel, as the EFI time