From patchwork Sat Jun 22 08:51:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167480 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1734188ilk; Sat, 22 Jun 2019 01:51:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg7NPtitV0yz2WeL/RlLWBjUc9DbJ2yE6LWZXC86u07k/QfILgWXRSVXVUQyYGIrN3zRAx X-Received: by 2002:a63:6b46:: with SMTP id g67mr14912066pgc.45.1561193486709; Sat, 22 Jun 2019 01:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561193486; cv=none; d=google.com; s=arc-20160816; b=hp/NSeTj85KtItsmurK0l3mn7A3x1+4uA6tiO5UXDYEyY5s2QvBPPFHktHNwmUxqOs LuY3l6rm4jIVLxxQjicJVRG9NDPmFCmObcJ/LB5nKPqIDA4zcJIvBBTm0rOd9DpmHSJt XjMmgIETxsTWI654od/QCDJZNhwK/MDxJUiVWV5eFPRn+WgjBqsO0CXoBQHub1k52i2u oLTdO9cvTxh9Wp/1hoMJqOEfdhUtNZszCN0VaePRALuNFuCtgpJEVWFguzbTvzp6O8cC 16GH+V9ZJ9NZUP0q2wih3cfZ1SDOKjJqOLi+OgRcUHiq7m/3v8p3aKQxhnGHpFCkIs0W 4DVA== 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 :dkim-signature; bh=qiN85MY5YnTwB3nQ80pJ/FSY8JMCGoluMGY1yE5pzt8=; b=XUS50EUcppjchedzBHRjj6FHbdCYChjgxc7QTO6Y8j13ZOi7a0ku5lDtfpM5aF3Tuv Yf5+hfL2peIODaC0pyYlzIT2nOJFmeOTdG/hnmlgWNpa/rW2pVETL+x3yRX+PJTher/Z ODjaYGllDTwuvTc6hNsI9Z5FB9jqAccS82ZdKmCgoiv73+ZvWQn4b36ZaFN6WOJcYmze aDFYPucPHThyLKJlvslYOem8IkGPY/hXq9h0J5aefRWFavAHLYkUxZs8mCl9b8fCwSU4 lP6zRb58WoX1Eptsqb9+4iVxemQx2p+KDHlzcLv/LO9/CnY2KfImDujmafdin93gdD// 9nkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H/p1qP5U"; 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 f16si5357664pjg.50.2019.06.22.01.51.26; Sat, 22 Jun 2019 01:51:26 -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; dkim=pass header.i=@linaro.org header.s=google header.b="H/p1qP5U"; 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 S1726465AbfFVIvX (ORCPT + 30 others); Sat, 22 Jun 2019 04:51:23 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45516 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbfFVIvS (ORCPT ); Sat, 22 Jun 2019 04:51:18 -0400 Received: by mail-wr1-f67.google.com with SMTP id f9so8687554wre.12 for ; Sat, 22 Jun 2019 01:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qiN85MY5YnTwB3nQ80pJ/FSY8JMCGoluMGY1yE5pzt8=; b=H/p1qP5UKrqbgx62rex5GvcEiP0tumRfLfdHFtTeGXRVnhy+Bc0wSAjxZkpJI2kT6U vQUfAVCPe9SfCqgFiRYWiEmlDFWx07zJylvpNpmMiWu8esFrF0nsSylVV71EWkolD9xQ S6t6QfIx1p643HMzcCMzaomCgLCtYVoT4th99SnrRo5wcclGgqXgD2Mkx7M81nBh7D8c FHSNPRsklt3XRZV1fmkYW6h+38Z1j8NhVaQ1GreT6T/aI81iqlGF30NUrqPj0xQozNpg HEyFXAK7Eufqhn0jAVrL7bYli/+XrGKo5PABFeIFVThkD2OuAz7cbiOlxuXxWaFMaFBO ZJyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qiN85MY5YnTwB3nQ80pJ/FSY8JMCGoluMGY1yE5pzt8=; b=UqUxfZxJ3LDSVbBMYTj+zDaUIRJxBertwxVyp4N/I3zUYlGYaWmzkhYudJ3W60IhoV s6tfkgJNa0L+80lp2XHBJn1Gz6NjXQWb9+6dGtgQRw+5Wl3Re9M+d9+3pRRNyoxSRRC8 P7lW7dEtinoXt9FluuhIme1yivxq9zrDiZHDYJpHYSM3BPbL1pksKWkna93ma9JfLtyt o4Olq7SUTjIeid/YtbsROl3lubS5kLTnvD7L4ckHAU8yrCWIpfofGbwY4r7E1IyNcfuS KlwQqGRluuqncQcu36bcn0u6ESUEBPuz0nqhi2G+fMQd+NImZcr26tCZe6V8IvxIL2Hc +jQg== X-Gm-Message-State: APjAAAU3wgEeFbw9MTF/ltaP83qq1h0u/KJUXbmi/g6QFeIiZb+JvADX qnNiSvJekrm3ch/WL6TZc5hpgQ== X-Received: by 2002:adf:f591:: with SMTP id f17mr2519691wro.119.1561193476680; Sat, 22 Jun 2019 01:51:16 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:4bd:3f91:4ef8:ae7e]) by smtp.gmail.com with ESMTPSA id v15sm4863589wrt.25.2019.06.22.01.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jun 2019 01:51:16 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Hans de Goede , Jonathan Richardson , Luo XinanX , "Prakhya, Sai Praneeth" , Qian Cai , Tian Baofeng Subject: [PATCH 4/4] efibc: Replace variable set function in notifier call Date: Sat, 22 Jun 2019 10:51:06 +0200 Message-Id: <20190622085106.24859-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190622085106.24859-1-ard.biesheuvel@linaro.org> References: <20190622085106.24859-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tian Baofeng Replace the variable set function from "efivar_entry_set" to "efivar_entry_set_safe" in efibc panic notifier. In safe function parameter "block" will set to false and will call "efivar_entry_set_nonblocking"to set efi variables. efivar_entry_set_nonblocking is guaranteed to not block and is suitable for calling from crash/panic handlers. In UEFI android platform, when warm reset happens, with this change, efibc will not block the reboot process. Otherwise, set variable will call queue work and send to other offlined cpus then cause another panic, finally will cause reboot failure. Signed-off-by: Tian Baofeng Signed-off-by: Luo XinanX Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efibc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c index 61e099826cbb..35dccc88ac0a 100644 --- a/drivers/firmware/efi/efibc.c +++ b/drivers/firmware/efi/efibc.c @@ -43,11 +43,13 @@ static int efibc_set_variable(const char *name, const char *value) efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data); memcpy(&entry->var.VendorGuid, &guid, sizeof(guid)); - ret = efivar_entry_set(entry, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_RUNTIME_ACCESS, - size, entry->var.Data, NULL); + ret = efivar_entry_set_safe(entry->var.VariableName, + entry->var.VendorGuid, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_RUNTIME_ACCESS, + false, size, entry->var.Data); + if (ret) pr_err("failed to set %s EFI variable: 0x%x\n", name, ret);