Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pefNo-0000WJ-FG for mharc-grub-devel@gnu.org; Tue, 21 Mar 2023 13:02:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pefNm-0000Ua-VG for grub-devel@gnu.org; Tue, 21 Mar 2023 13:02:46 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pefNi-0005ms-2E for grub-devel@gnu.org; Tue, 21 Mar 2023 13:02:44 -0400 Received: by mail-qt1-x82a.google.com with SMTP id t19so4602808qta.12 for ; Tue, 21 Mar 2023 10:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; t=1679418160; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=GxlK+nwNHbk1FvS6ZddSC6ACUtKJprhA9rzGIiLnGFM=; b=RRkgpA9kHOpgMQkL5as4MKElMn0Z/HUYXbQ2iH8amjtSxk7V7Cp6Vv3rKyDOF66EuN 4MABx+dn365B8drzE7/iJPJaIjW4hN+CEk6JoMF8Zhwukd6bxbB6RG+Ezi+WU/EBO849 60Jgatdjg5oDI9qbjLHi2E/XkFGF533uhgXZzr8wTNSvptb/kN4IAiyjPBueENHcmxFm M5vC9cm1nnXD1XoN0Z2kwiCkj77+U+zHo/a/+3645kKE+ygO4x1VE+7W8uUU7Gl4ZLO0 llfbpickc0k7L7oOXQUPrPC/hLaV8/t3EyBvmrWz3PXJ/BmdOvsV5aOlvx11QlgVA7jd iUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679418160; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GxlK+nwNHbk1FvS6ZddSC6ACUtKJprhA9rzGIiLnGFM=; b=L4HjLC8+Tq/0kKHzWyzFVxrEyL8DGewE7tIdPniP2LBioHcY8ZcmVC+Q9rridBxerr NnPDUFlhRNnuJGmxGAD0kUlaf0zD+wNXNVJkhLW35t3DrXG9a8P8Rq8sGDuRSXL3AA+B zAkqmN+DIUfOlEq0PswxyOvR+19EyzyP79XQqN39xNtjLa2PaOHeD2y31tX4Jv+RVr+G X8opBf7aZL7YYSOD3UL5+Cgbqe99N1duCiJonX72hMF+v9ZgVG797PSD7+VpEso9A/lh C07yvUWiaHChfRKS5FPkzJkFr/Vri5cp2Vrgj+ai48pbB3eaG49KeWkCjfl3Vv/7RhsB lHKA== X-Gm-Message-State: AO0yUKXpUrHtUHzToSXMMpv6PcJNLuAowK+FVetbReR1aOPv/wMe28Q8 vLvm14uvSIOfTke2xuux8MFYTw== X-Google-Smtp-Source: AK7set+lQHVjwTQYzw/LT8Y3O3PKA4p2d8IoD0ghGW+ZGHzWMJOuPqj59RKCCxDw4/Mw3iH4jAOSbA== X-Received: by 2002:ac8:5988:0:b0:3b9:bc8c:c1fa with SMTP id e8-20020ac85988000000b003b9bc8cc1famr988973qte.5.1679418159872; Tue, 21 Mar 2023 10:02:39 -0700 (PDT) Received: from [10.41.0.94] ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id y2-20020a37f602000000b0073b878e3f30sm9637279qkj.59.2023.03.21.10.02.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Mar 2023 10:02:39 -0700 (PDT) Message-ID: Date: Tue, 21 Mar 2023 17:02:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Glenn Washburn Subject: Re: [RFC PATCH] gdb: Add more support for debugging on EFI platforms To: Robbie Harwood , grub-devel@gnu.org, Daniel Kiper Cc: Peter Jones References: <20230227213526.2379718-1-development@efficientek.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=development@efficientek.com; helo=mail-qt1-x82a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2023 17:02:47 -0000 On 3/16/23 21:05, Robbie Harwood wrote: > Glenn Washburn writes: > >> On 3/9/23 23:00, Robbie Harwood wrote: >>> Glenn Washburn writes: >>> >>>> If the configure option --enable-efi-debug is given, then enable the >>>> printing early in EFI startup of the command needed to load symbols for >>>> the GRUB EFI kernel. This is needed because EFI firmware determines where >>>> to load the GRUB EFI at runtime, and so the relevant addresses are not >>>> known ahead of time. This is not printed when secure boot is enabled. >>>> >>>> The command is a custom command defined in the gdb_grub GDB script. So >>>> GDB should be started with the script as an argument to the -x option or >>>> sourced into an active GDB session before running the outputted command. >>>> >>>> Also a command named "gdbinfo" is enabled which allows the user to print >>>> the gdb command string on-demand, which can be valuable as the printing >>>> early in EFI startup is quickly replaced by other text. So if using a >>>> physical screen it may appear too briefly to be registered. >>>> >>>> Co-developed-by: Peter Jones >>>> Signed-off-by: Glenn Washburn >>>> --- >>>> This is patch 9 from the v6 "GDB script fixes and improvements" series, with >>>> one modification. Now the gdbinfo command will print the gdb load command >>>> even when the configure option is not enabled (though still not when lockdown >>>> is enabled). >>>> >>>> Robbie had 2 concerns with the last patch. >>>> >>>> 1. Does this need to be configurable? >>>> * I responded that this was requested by Daniel because of concerns about >>>> it breaking silent boot and it seemed reasonable to me, but that I don't >>>> have a strong opinion. I've left it configurable until Dnaiel weighs in. >>> >>> Yeah, I think these concerns are valid. The version in the rhboot >>> tree gates printing on an env var. Right now, it seems to me that: >>> >>> - we want it to be default-off because silent boot >> >> I understand you to be talking about a default-off at runtime, not >> built time. Right now there is a configure option which defaults to >> off, is this acceptable? > > Indeed, I'm talking about runtime configurability. Build-time > configurability means it's either always on (bad) or we have to rebuild > in order to debug (annoying, interacts poorly with scureboot). > >>> - we want to have the ability to reenable without rebuilding because >>> secureboot, convenience, etc. >> >> This would be great, but how do you propose that this would work? This >> patch will print very early in EFI init. We can't use GRUB variables. We >> probably could use EFI variables, but this needs to be well defined (and >> not by me, since I don't have this requirement). I'm not sure if the >> GRUB env block is available at this point, but that might be an option. >> >> Can you point me to RH's patch you've referred to? Does it meet this >> requirement, and if so how? > > I thought you were basing your work off it, given the "Co-developed-by" > and your review on v1: > https://lists.gnu.org/archive/html/grub-devel/2021-10/msg00076.html Yes, I am off that patch. I was thinking things had changed or there were other patches to get the requirement met. Thanks for providing the info anyway. Looks like nothing has changed and the missing piece is the envblk from an EFI variable patch. > > (v2 was > https://lists.gnu.org/archive/html/grub-devel/2021-11/msg00006.html and > the versions we're shipping are > https://github.com/rhboot/grub2/commit/93803e83135e074ed5a3e7f67af22538896dbefe > and > https://github.com/rhboot/grub2/commit/c314270222b4adffa16840e3ca764d793e93a0e8 > ) > > As you say, the grub env block isn't available (module loading happens > before filesystems). We have an additional patch that allows the use of > an EFI variable for setting grubenv: > https://github.com/rhboot/grub2/commit/22a11bfa59ff8f239cfe8698274281bc919673dc Looks like the above commit relies on this commit: https://github.com/rhboot/grub2/commit/636612cec23868d9165d79f2c3e2a9ea6c278c38 > which lets one do e.g. > > grub2-editenv ./grubenv set debug=gdb,modules,dl > { printf '\x07\x00\x00\x00' ; cat ./grubenv ; } > GRUB_ENV-91376aff-cba6-42be-949d-06fde81128e8 > cp GRUB_ENV-91376aff-cba6-42be-949d-06fde81128e8 /sys/firmware/efi/efivars/ A bit off topic, but perhaps this could be wrapped in an option to grub2-editenv and doing something like: grub2-editenv -E set debug=gdb,modules,dl > and then have configuration for the next boot. Javier informally > proposed this to the list a few years ago for ZFS-related things: > https://lists.gnu.org/archive/html/grub-devel/2020-02/msg00045.html but > I don't think it was ever followed up on, possibly because ZFS is not > one of our use cases :) > > I'm happy to formally propose it, or feel free to include/adapt it if > it's helpful to you, etc.. The envblk EFI variable seems to me to be a nice feature to have, so I'm supportive in general. One concern I have is that this efi-envblk feature is a non-trivial amount of code for this particular patch to be dependent on. So if the efi-envblk is proposed and doesn't get included for this release cycle, neither will this patch. I would say yes to submitting the efi-envblk patches, regardless of what we do with this patch. And I'd like to hear Daniel's thoughts on this. Glenn