Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4102170imj; Tue, 12 Feb 2019 09:48:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbH06YwwzdqPGjs715H2tzM40cQ2Z3tnF638F1xffMSvSzgqXTTo+sBRWCcnRUELoY9K4Ut X-Received: by 2002:a63:e80e:: with SMTP id s14mr4692358pgh.30.1549993705501; Tue, 12 Feb 2019 09:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549993705; cv=none; d=google.com; s=arc-20160816; b=lk9PucOuQGdulIvdwaqtlOpYSqA1TlJS3YZgEaLdzlbzbRUKF1klJGhcSoh6dxwoy8 jc5zLmhsygoNktOEXSHcyIhLVXW3pqZoQ0OU2PpfhtuK2Zj1Y5fLuIf1nmGfzjylXIDR UQjs1ALjQor5AJLepek2szNF4nB1fdRrbAqA/9BBcdPbqrxAWe7PUm+2jmQDhNKJxI85 mD+P2pHUbDOA8RvvN3keMCWdERZjI0+5HMBwxDoLLdmlJwyMmcEh3X9sFolJFT6Dw1xy 1a1bZkuVMSA/JAOdwpXdl25zpQjGqab5lbe/Q9ZP3XZtxP07htXqk0dmJn1FDaRZ7p+j bDvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4gJNR66jGd5ZeRKDO6gEvADyebKSZ9E/2xyWw0FjXoQ=; b=kHPMJP4psFQzBH4+G6LvbG0XuJAyXebWGQOPypgrwjVSOK6GUXbakqORrBh301ht5v W1peX18hl6fjiIGi13164KmVNd+lOO0cnY/l+gT75H/+euRUPDzNeQjcFUq2Bx0rMwPM U4AqA9uN+yhJWpUICNcIVNO77/mFYCQvDwjkeWCQzEx7qYk/6zwam29C1lqEfNfeOuEC le587BstOhewDJ8VuadcEHdN3k577lbduhGqvAqnjiSkV7gwHrMwPuuwRaxiw9HU3Y8A GN6pnOlzQEouJsbmIzENTGl66M1I4HT5xNHyISATypPRSyb0bJyd1drKceN8pQAHGBRK stIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zDNXXFmc; 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 d25si12998757pgd.88.2019.02.12.09.48.08; Tue, 12 Feb 2019 09:48:25 -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=zDNXXFmc; 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 S1730776AbfBLR0V (ORCPT + 99 others); Tue, 12 Feb 2019 12:26:21 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:36847 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730035AbfBLR0U (ORCPT ); Tue, 12 Feb 2019 12:26:20 -0500 Received: by mail-it1-f196.google.com with SMTP id c9so9566353itj.1 for ; Tue, 12 Feb 2019 09:26:19 -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; bh=4gJNR66jGd5ZeRKDO6gEvADyebKSZ9E/2xyWw0FjXoQ=; b=zDNXXFmc0KZT1twb0MFVuCjmtU9sPNsoH1XeWRxrRGvDHVrQ1tF4PoZasv+R/M/rTj fXOmk7m+V197WTlREQntDkQAfbPd13vShow1DA/6P2QatzqO4Pcl1uqCB5/zP8oBFwQQ JSV6lmFYzz1DEuzlgiam8ertX/jo4NjnemZSMs0lgc8V9+gYNMWHw0yBqU0P2aWLbOp0 nVLwQRG6BRBsbVWZyZVj9vrOqt2f8Y+kv3aUHrqwH296cYCKZiFbp4VYph63zQVGfhcM HrVGNqzHK3+JYHib3GGWhwIQR/RXf758JV41dSuAAvay5gb77M7EARvPwy9Xswl0Bd2C L1jA== 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; bh=4gJNR66jGd5ZeRKDO6gEvADyebKSZ9E/2xyWw0FjXoQ=; b=WZdW7X1x5a4HJ4wBjUcrhd5TMhBcxQ7kvli7Y3R5BiRfSdNDUx/ubUG/2hYvMYta24 /7+bSDdHZxo1zGt4JlZf/E89XRU4hQ6iSQBmkUs+sf85bSHvwTGOd9RmT6gM58XqzbVQ OKuNqPtBmqZ/6Ny1lRmdOR/Dk9TcGH53I5o5c0DT+zK3GRygrqcJTQoQVHK1OspmiwQl NBdKliqMNe6GPEgpYOIaJQ3XcglUk3jXcndGmw8sAEIDIeMCqyDBnT4RgE8E4eoEM78R KEYk6eKNQMGnSLNTFTcm4nBmIz1F5npSnFDCbEB8fAmimi2kJBj4ir9Z4s/1C3BqLy6R QgIw== X-Gm-Message-State: AHQUAuYpDY0CYEBN4unrRvGSQkkcxEbHVnB0Qn2dc5NnLsF0fXX612Iw OobZwYi0PCV2mZRx4pugELBuJGXWUGjIkxvr3gklIg== X-Received: by 2002:a5e:9704:: with SMTP id w4mr2978699ioj.60.1549992379176; Tue, 12 Feb 2019 09:26:19 -0800 (PST) MIME-Version: 1.0 References: <20190207042234.25109-1-hedi.berriche@hpe.com> <20190207042234.25109-2-hedi.berriche@hpe.com> <20190207173808.GE6398@sarge.linuxathome.me> <20190212172500.GB6398@sarge.linuxathome.me> In-Reply-To: <20190212172500.GB6398@sarge.linuxathome.me> From: Ard Biesheuvel Date: Tue, 12 Feb 2019 18:26:06 +0100 Message-ID: Subject: Re: [Patch v2 1/4] efi/x86: turn EFI runtime semaphore into a global lock To: Ard Biesheuvel , Linux Kernel Mailing List , Thomas Gleixner , Bhupesh Sharma , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-efi , "the arch/x86 maintainers" , Russ Anderson , Mike Travis , Dimitri Sivanich , Steve Wahl , stable 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 Tue, 12 Feb 2019 at 18:25, Hedi Berriche wrote: > > On Thu, Feb 07, 2019 at 17:38 Hedi Berriche wrote: > >On Thu, Feb 07, 2019 at 16:05 Ard Biesheuvel wrote: > >>On Thu, 7 Feb 2019 at 05:23, Hedi Berriche wrote: > >>> > >>>Make efi_runtime_lock semaphore global so that it can be used by EFI > >>>runtime callers that may be defined outside efi/runtime-wrappers.c. > >>> > >>>Also now that efi_runtime_lock semaphore is no longer static, rename it > >>>to efi_runtime_sem so it doesn't clash with the efi_runtime_lock spinlock > >>>defined in arch/x86/platform/efi/efi_64.c when CONFIG_EFI_MIXED is > >>>enabled. > >>> > >>>The immediate motivation of this change is to serialise UV platform BIOS > >>>calls using the efi_runtime_sem semaphore. > >>> > >>>No functional changes. > >>> > >>>Cc: Russ Anderson > >>>Cc: Mike Travis > >>>Cc: Dimitri Sivanich > >>>Cc: Steve Wahl > >>>Cc: stable@vger.kernel.org > >>>Signed-off-by: Hedi Berriche > >> > >>Hello Hedi, > > > >Hi Ard, > > > >>Same feedback as on v1: please don't rename the lock. > > > >With the efi_runtime_lock semaphore being no longer static, not renaming it > >will cause a compile failure as it will clash with the declaration of the > >efi_runtime_lock *spinlock* in arch/x86/platform/efi/efi_64.c in the > >CONFIG_EFI_MIXED case. > > Ard, > > Any comments on whether resolving the conflict between > > {efi_runtime_lock, drivers/firmware/efi/runtime-wrappers.c} > > and > {efi_runtime_lock, arch/x86/platform/efi/efi_64.c} > > provides the required justification for renaming the efi_runtime_lock semaphore? > Hello Hedi, No it doesn't. I responded 5 days ago with a suggestion on how to address this instead. > Cheers, > Hedi. > > >>>--- > >>> drivers/firmware/efi/runtime-wrappers.c | 60 ++++++++++++------------- > >>> include/linux/efi.h | 3 ++ > >>> 2 files changed, 33 insertions(+), 30 deletions(-) > >>> > >>>diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c > >>>index 8903b9ccfc2b..ec60d6227925 100644 > >>>--- a/drivers/firmware/efi/runtime-wrappers.c > >>>+++ b/drivers/firmware/efi/runtime-wrappers.c > >>>@@ -53,7 +53,7 @@ struct efi_runtime_work efi_rts_work; > >>> * @rts_arg<1-5>: efi_runtime_service() function arguments > >>> * > >>> * Accesses to efi_runtime_services() are serialized by a binary > >>>- * semaphore (efi_runtime_lock) and caller waits until the work is > >>>+ * semaphore (efi_runtime_sem) and caller waits until the work is > >>> * finished, hence _only_ one work is queued at a time and the caller > >>> * thread waits for completion. > >>> */ > >>>@@ -144,7 +144,7 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call) > >>> * none of the remaining functions are actually ever called at runtime. > >>> * So let's just use a single lock to serialize all Runtime Services calls. > >>> */ > >>>-static DEFINE_SEMAPHORE(efi_runtime_lock); > >>>+DEFINE_SEMAPHORE(efi_runtime_sem); > >>> > >>> /* > >>> * Calls the appropriate efi_runtime_service() with the appropriate > >>>@@ -233,10 +233,10 @@ static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(GET_TIME, tm, tc, NULL, NULL, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -244,10 +244,10 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm) > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(SET_TIME, tm, NULL, NULL, NULL, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -257,11 +257,11 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(GET_WAKEUP_TIME, enabled, pending, tm, NULL, > >>> NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -269,11 +269,11 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(SET_WAKEUP_TIME, &enabled, tm, NULL, NULL, > >>> NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -285,11 +285,11 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name, > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(GET_VARIABLE, name, vendor, attr, data_size, > >>> data); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -299,11 +299,11 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size, > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(GET_NEXT_VARIABLE, name_size, name, vendor, > >>> NULL, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -315,11 +315,11 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name, > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(SET_VARIABLE, name, vendor, &attr, &data_size, > >>> data); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -330,12 +330,12 @@ virt_efi_set_variable_nonblocking(efi_char16_t *name, efi_guid_t *vendor, > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_trylock(&efi_runtime_lock)) > >>>+ if (down_trylock(&efi_runtime_sem)) > >>> return EFI_NOT_READY; > >>> > >>> status = efi_call_virt(set_variable, name, vendor, attr, data_size, > >>> data); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -350,11 +350,11 @@ static efi_status_t virt_efi_query_variable_info(u32 attr, > >>> if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) > >>> return EFI_UNSUPPORTED; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(QUERY_VARIABLE_INFO, &attr, storage_space, > >>> remaining_space, max_variable_size, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -369,12 +369,12 @@ virt_efi_query_variable_info_nonblocking(u32 attr, > >>> if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) > >>> return EFI_UNSUPPORTED; > >>> > >>>- if (down_trylock(&efi_runtime_lock)) > >>>+ if (down_trylock(&efi_runtime_sem)) > >>> return EFI_NOT_READY; > >>> > >>> status = efi_call_virt(query_variable_info, attr, storage_space, > >>> remaining_space, max_variable_size); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -382,11 +382,11 @@ static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) > >>> { > >>> efi_status_t status; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL, > >>> NULL, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -395,14 +395,14 @@ static void virt_efi_reset_system(int reset_type, > >>> unsigned long data_size, > >>> efi_char16_t *data) > >>> { > >>>- if (down_interruptible(&efi_runtime_lock)) { > >>>+ if (down_interruptible(&efi_runtime_sem)) { > >>> pr_warn("failed to invoke the reset_system() runtime service:\n" > >>> "could not get exclusive access to the firmware\n"); > >>> return; > >>> } > >>> efi_rts_work.efi_rts_id = RESET_SYSTEM; > >>> __efi_call_virt(reset_system, reset_type, status, data_size, data); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> } > >>> > >>> static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, > >>>@@ -414,11 +414,11 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, > >>> if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) > >>> return EFI_UNSUPPORTED; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(UPDATE_CAPSULE, capsules, &count, &sg_list, > >>> NULL, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>@@ -432,11 +432,11 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, > >>> if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) > >>> return EFI_UNSUPPORTED; > >>> > >>>- if (down_interruptible(&efi_runtime_lock)) > >>>+ if (down_interruptible(&efi_runtime_sem)) > >>> return EFI_ABORTED; > >>> status = efi_queue_work(QUERY_CAPSULE_CAPS, capsules, &count, > >>> max_size, reset_type, NULL); > >>>- up(&efi_runtime_lock); > >>>+ up(&efi_runtime_sem); > >>> return status; > >>> } > >>> > >>>diff --git a/include/linux/efi.h b/include/linux/efi.h > >>>index 45ff763fba76..930cd20842b8 100644 > >>>--- a/include/linux/efi.h > >>>+++ b/include/linux/efi.h > >>>@@ -1745,6 +1745,9 @@ extern struct efi_runtime_work efi_rts_work; > >>> /* Workqueue to queue EFI Runtime Services */ > >>> extern struct workqueue_struct *efi_rts_wq; > >>> > >>>+/* EFI runtime semaphore */ > >>>+extern struct semaphore efi_runtime_sem; > >>>+ > >>> struct linux_efi_memreserve { > >>> int size; // allocated size of the array > >>> atomic_t count; // number of entries used > >>>-- > >>>2.20.1 > >>> > > > >-- > >Be careful of reading health books, you might die of a misprint. > > -- Mark Twain > > -- > Be careful of reading health books, you might die of a misprint. > -- Mark Twain