Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp490607imn; Fri, 29 Jul 2022 13:24:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uAgnf5wB4TEvOz5DDjwsV9xUyYGNsn08amjgQw1bzY3FNq7/noogT2jqx1nz83NOZ7jbGk X-Received: by 2002:a17:907:87b0:b0:72f:11fc:86c1 with SMTP id qv48-20020a17090787b000b0072f11fc86c1mr4115651ejc.449.1659126241391; Fri, 29 Jul 2022 13:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659126241; cv=none; d=google.com; s=arc-20160816; b=eacYA5bfojMH0Uq6/vkwyBjNF4nCZSKrNgOcgpcO82fL01Twtp1icJAIjyAvoxwafB H6kkfiAGM52FiXO8jM+7UCUrhvaFLVtFlfH2IJsX/5f/0BQXNe3zfCpnY+CWi6AD4LXA W+HJZyymUNX4nHHUyZ2Tzu4nbcw7GpfTYBm4gHnHq4q/T5/lYDb4VeESvyZ8VoraRKI9 tRVw0D/KZJ8FnfNV5ifafruBFiwDELVchOOicardCUvb5WSYmlrFqKj11EZaJGQaPFVp qL2Ex+p1TijPVgCEmfu++XMETYOKLfbs8Px9XYu4FXcSaRQX1uFCCnLsKT9snCAflKVe ltrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U4kyy3+iPq0es8I3IOuV/SecAyAqLgCBHGO4baBSJXY=; b=mgltG0dnse8YMeP0te8b/0ZOf0ro7BVK+H8OWeYj42ZpBa7YLLGaNZJpCHXGEc+Q+U /MvG5g5eER6YVfmMDkeAi8VtezR1Vc6aQBebXTBmZ6+RW/0QdKaRUmgzxzBlBdwC/+Ht WKrRqx3qT0HR+w4gOOpFkpvQrv/V1DkHHbvfmPNSi6S2PHLEUFFZZEYMPNZwTFILTJdg mOqIV6xA0RfiGMTUAbgyjEjsfNwoQ0goLiqfN+9m9SYXYLm1z8R1q/6IKJuSdj8C1qqs IvjD+wHkfzq+ULXmBwZG4RSsTQtEjP3Je8wU9oqGskGpXfcBXG3CSfq6nV/1jIWmBHF2 cK6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=UPdILmC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a1709060e4b00b0072b58288194si3684014eji.293.2022.07.29.13.23.36; Fri, 29 Jul 2022 13:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=UPdILmC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238871AbiG2TqK (ORCPT + 99 others); Fri, 29 Jul 2022 15:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237659AbiG2TqI (ORCPT ); Fri, 29 Jul 2022 15:46:08 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A190865FD; Fri, 29 Jul 2022 12:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=U4kyy3+iPq0es8I3IOuV/SecAyAqLgCBHGO4baBSJXY=; b=UPdILmC1M4E+vNWh+skga8xTtx 0PhIN33ICezQxaE6dsPX2HxW7tZZw2jdmzxkugjqLiZHUEmL+GeSUmCJeJN9BfRveZy/RLVOLDaUS 47Pq9nsJETnflbtM0ZwdWQSFusD6TgY75FM6RRA2FBU5rbDvCOCh5jnlwmFuqB+KXPLD7zc6pzkll pqQVQz+S/kYsM2Mhz+e/fT/J6P7HwuGCq+JHplCLgTFgd5XCWueYcJTuupLbxu8cXF8BTA1LgXNve Ak8NcHc8XfM8EgAz9+a2qR/06y+h9KcSHvCIeW+iLtKXHcZt4d8go5ntzyfMP2yv6IemNzhZzjCTM 24ubXt2Q==; Received: from [177.83.209.223] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1oHVvk-00BM8Y-Lf; Fri, 29 Jul 2022 21:45:55 +0200 From: "Guilherme G. Piccoli" To: ardb@kernel.org, linux-efi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, anton@enomsg.org, ccross@android.com, keescook@chromium.org, matt@codeblueprint.co.uk, mjg59@srcf.ucam.org, tony.luck@intel.com, "Guilherme G. Piccoli" Subject: [PATCH v2 0/3] The UEFI panic notification mechanism, 2nd round Date: Fri, 29 Jul 2022 16:45:29 -0300 Message-Id: <20220729194532.228403-1-gpiccoli@igalia.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey folks, this is the 2nd iteration of the patchset adding a simple mechanism to notify the UEFI firmware about a panic event in the kernel. V1 here: https://lore.kernel.org/lkml/20220520195028.1347426-1-gpiccoli@igalia.com/ First thing, the differences in this V2: - Ardb response in V1 mentioned a refactor aimed for v5.20 that removes an obsolete/confusing way of setting EFI variables - this led to a weird condition, deleted variables stayed in sysfs after deletion. Well, I've refactored the code based on efi/next, so I'm using the recommended API now - thanks a bunch for the advice Ardb! - I've changed NULL-terminating char in patch 1 to the format I've seen in Ardb's code, L'\0'. - Patch 2 is new, it's somewhat a fix for a patch only in efi/next, part of the efivar refactor. In the V1 review, it was mentioned we could maybe use efi-pstore as a way to signal the firmware about a panic event - in the end, the efi-pstore mechanism can collect a dmesg, so it's even richer in the information level. But I disagree that it is the way to go, for 3 main reasons: a) efi-pstore could be impossible to use, if the users are already using another pstore backend (like ramoops), which is _exactly_ our case! Of course, we could rework pstore and allow 2 backends, quite a bit of work, but...see next points! b) Even if (a) is a not an issue, we have another one, even more important: signaling the firmware about a panic is *different* than collecting a bunch of data, a full dmesg even. This could be considered a security issue for some users; also, the dmesg collected consumes a bunch more memory in the (potentially scarce) UEFI available memory. Although related, the goal of pstore is orthogonal to our mechanism here: users rely on pstore to collect data, our proposal is a simple infrastructure to just let the firmware know about a panic. Our kernel module also shows a message and automatically clears the UEFI variable, so it tracks a single panic, whereas efi-pstore logs are kept by default, in order to provide data to users. c) Finally, it's faster and less "invasive"/risky to just write a byte in a variable on a panic event than having a ksmg dumper collecting the full dmesg and writing it to the UEFI memory; again, some users wish to have the logs, but not all of them. With all of that said, I think this module makes sense, it's a very simple solution that opens doors to firmware panic handling approaches, like in our proposed case (a different splash screen on panic). Finally, the variable name (PanicWarn) and value (0xFF by default, can be changed by a module parameter) are just my personal choices but I'm open to suggestions, not strongly attached to them heh Thanks again for the reviews/suggestions! Cheers, Guilherme Guilherme G. Piccoli (3): efi: Add a generic helper to convert strings to unicode efi: efibc: Guard against allocation failure efi-panic: Introduce the UEFI panic notification mechanism drivers/firmware/efi/Kconfig | 10 ++++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi-panic.c | 89 +++++++++++++++++++++++++++++++ drivers/firmware/efi/efi-pstore.c | 4 +- drivers/firmware/efi/efibc.c | 11 ++-- include/linux/efi.h | 18 +++++++ 6 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 drivers/firmware/efi/efi-panic.c -- 2.37.1