Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1583442imu; Sat, 26 Jan 2019 06:12:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN73TUuqc77nz9wUrtiI7TvZSlgVeurTCWP+vhP3Pi7wpUDPKk17sDH6TYCGQbN7fWd+++IF X-Received: by 2002:a63:da14:: with SMTP id c20mr12894231pgh.233.1548511960703; Sat, 26 Jan 2019 06:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548511960; cv=none; d=google.com; s=arc-20160816; b=xtXFbhOP3eMixvtacQMaS4IgkwDuVZ6Znam/089h9dzFkwVO1qlsPRPjYWMyhqaXRp +rZ4IplOzxwLb3SBvWt5QrWh09EXQMMt6KU92o+xTSiXLpCgnbGdkfzdaINJVFlsFbRG EVCI4WmEsWIBnYo1NrG5TLxwbtUeMCMxOX/Kc4UPqOOcsD1ULax/Lkpl3TH5YHJQtqEp mijvAhOMOVr6Ci1z4tfn5xazGpYTaFGDOvLMQHUgmOKsoziwSRldt8ls8WpACqzb/Yek D4VJtnFEqZvSTfP8A/PFZ3BmCUUnKB0UqXHYllYu7pGCdLv7tB3QerjJm0iskN2kG8bQ azdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7yiQhDgD+LoNYrE33H1YnbwzccUcgvQS6K9T24TtKbk=; b=Q2GKDX8cyONTmLvaXHhWqFatHGcaW7F2l2IAD3PxZTmjkeRLtTwX5V5PjMzQz97Ou8 8QBC+denI9aOQ0q7HHPMm8tj78a9ccldbkslKBcm3iIo7LfGAy5jV7Q53xEWrLDX6UZM 3r6Drc4sHZtenHWKAH9lncZ6K7JQ5F7yXXqk7+gs6T9Kh9BRNKa9H/T+bbAVG7yWRv3C zPPhoDWco3R7oYjKzpkEXNIM86IJJv49uGCQ0zEv8LGSmYIde2iddokkAvKa+XsxbNF1 l9FUOQFGZEcNFZ+idzJbHeLcZwoot7Lv49lZFHBAWt3ooUti75dnzAbhvDj7eodUzgsG Rt9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XEvVF/wW"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b124si29253612pfg.47.2019.01.26.06.12.24; Sat, 26 Jan 2019 06:12:40 -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=@linaro.org header.s=google header.b="XEvVF/wW"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726145AbfAZOLC (ORCPT + 99 others); Sat, 26 Jan 2019 09:11:02 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:35344 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfAZOLB (ORCPT ); Sat, 26 Jan 2019 09:11:01 -0500 Received: by mail-it1-f193.google.com with SMTP id p197so13639551itp.0 for ; Sat, 26 Jan 2019 06:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7yiQhDgD+LoNYrE33H1YnbwzccUcgvQS6K9T24TtKbk=; b=XEvVF/wW330eCALXbqwNSFUdRYJozWSXLBF1SRbyB+7vNyFk/g9VO2Hix0l0wGwI8C EH7Bx9aRGpCCAHBRsbFy7zle1MHQvRiLdU4Q4fYymtXjV8cEu16fHaJWbvX9xzrypbXw c1UnPu1+nHTfUtnSIpfWgwD4H6iL56l/7FUOs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7yiQhDgD+LoNYrE33H1YnbwzccUcgvQS6K9T24TtKbk=; b=G2yjad2bJxnMnUC5BH5sNNCCcBczBQSNn6JYBzTHTyWznqq11qVtcqWns0yecJpL02 gU2IBDwU/V3s6er68zwpKViKp1Ow+5KAUw+jr4DEzpxQ6sRktYBM/llBYR4712D2eUQY v4S8Sy77PEFTthxyh4jeMCngV9tKBJ98lortIEFOa/OCO31/ndlWYJmYRT7hL/n2Gu97 PMexlZoz211i3BmfWxWEF3S3fayBXtT3B+1+BdRfX+yb95qe9yHVGZUlx2zOrrQep2yi j1xP/IQ8gM138Hq/yOh5TpJphcE/ge3jzJjMQvzQUiKY1a9OSrlbJmGWfOwVDsi20tF2 n60Q== X-Gm-Message-State: AJcUukdUCmsgA2rRrUXScu9qrrwhh9du6va4QbpZhiBxAhkbz0CZiWx6 LnXuxDwoQOMTx4QIv0oZXC272/BtKsyntN4DrIjHvg== X-Received: by 2002:a05:660c:4b:: with SMTP id p11mr6735212itk.71.1548511860436; Sat, 26 Jan 2019 06:11:00 -0800 (PST) MIME-Version: 1.0 References: <20190109104541.25733-1-hedi.berriche@hpe.com> <20190109104541.25733-4-hedi.berriche@hpe.com> In-Reply-To: <20190109104541.25733-4-hedi.berriche@hpe.com> From: Ard Biesheuvel Date: Sat, 26 Jan 2019 15:10:49 +0100 Message-ID: Subject: Re: [PATCH 3/3] x86/platform/UV: use efi_runtime_sem to serialise BIOS calls To: Hedi Berriche Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "the arch/x86 maintainers" , linux-efi , Linux Kernel Mailing List , Russ Anderson , Mike Travis , Dimitri Sivanich , Steve Wahl 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 On Wed, 9 Jan 2019 at 11:46, Hedi Berriche wrote: > > Calls into UV firmware must be protected against concurrency, use the > now visible efi_runtime_sem lock to serialise them. > > Signed-off-by: Hedi Berriche > Reviewed-by: Russ Anderson > Reviewed-by: Mike Travis > Reviewed-by: Dimitri Sivanich > Reviewed-by: Steve Wahl > --- > arch/x86/include/asm/uv/bios.h | 3 ++- > arch/x86/platform/uv/bios_uv.c | 25 ++++++++++++++++++++++--- > 2 files changed, 24 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/include/asm/uv/bios.h b/arch/x86/include/asm/uv/bios.h > index 4eee646544b2..33e94aa0b1ff 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 Nit: please add a trailing comma so the next patch looks cleaner. > }; > > /* Address map parameters */ > diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c > index cd05af157763..92f960798e20 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) > +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; > @@ -44,13 +45,26 @@ s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) > * If EFI_OLD_MEMMAP is set, we need to fall back to using our old EFI > * callback method, which uses efi_call() directly, with the kernel page tables: > */ > - if (unlikely(test_bit(EFI_OLD_MEMMAP, &efi.flags))) > + if (unlikely(efi_enabled(EFI_OLD_MEMMAP))) This is an unrelated change. You should at least mention it in the commit log, or put it in a separate patch. > ret = efi_call((void *)__va(tab->function), (u64)which, a1, a2, a3, a4, a5); > else > ret = efi_call_virt_pointer(tab, function, (u64)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_runtime_sem)) > + return BIOS_STATUS_ABORT; > + > + ret = __uv_bios_call(which, a1, a2, a3, a4, a5); > + up(&efi_runtime_sem); > + > + 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_runtime_sem)) > + 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_runtime_sem); > + > return ret; > } > > -- > 2.20.0 >