Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jVkQR-0007ed-IU for mharc-grub-devel@gnu.org; Mon, 04 May 2020 19:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVkQP-0007ZF-Iw for grub-devel@gnu.org; Mon, 04 May 2020 19:23:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVkQO-0004kf-E4 for grub-devel@gnu.org; Mon, 04 May 2020 19:23:01 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 044NHnXY096351; Mon, 4 May 2020 23:22:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=jYXt3EJCMiPdjYydXu4t6OC3I4vDqHFJoMB9afpxeEI=; b=gBBJka3gKNAbB9T8BSlLnaC7stEyENKaM6etxROEQJ6krYvC4lK063afjI68Qpk6/eNs RobDw7fvVadTmP4Ae56yrUbnBVTWcYz8ioXsD0FIZcqH/EAsXUTy2YrBwY/20hCmfTiq udwQWjDtolqVYyFQQawYrDYyrLXx4nciOC5JJa8Ll0imjVhuJdfSDWOD0MTIPFwiWv6P BZeLxlePa0HlkBm6q7DaONRJmWSoVO5xgdBuowa5pYcDTPuQOF3nFXJwt8m+tJehijM/ PxB9y9tysMkbz3y3IdJ8WWI8fuOaRHsnG/zWMg9ALNV2WDP9q/vIqMEhBrEw3lipKklJ kQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30s1gn1n5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 May 2020 23:22:53 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 044NLcZP139984; Mon, 4 May 2020 23:22:53 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30t1r3j11h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 May 2020 23:22:53 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 044NMqa3003613; Mon, 4 May 2020 23:22:52 GMT Received: from tomti.i.net-space.pl (/10.175.189.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 May 2020 16:22:50 -0700 From: Daniel Kiper To: grub-devel@gnu.org, linux-kernel@vger.kernel.org, trenchboot-devel@googlegroups.com, x86@kernel.org Cc: alexander.burmashev@oracle.com, andrew.cooper3@citrix.com, ard.biesheuvel@linaro.org, dpsmith@apertussolutions.com, eric.snowberg@oracle.com, javierm@redhat.com, kanth.ghatraju@oracle.com, konrad.wilk@oracle.com, krystian.hebel@3mdeb.com, lukasz.hawrylko@linux.intel.com, michal.zygowski@3mdeb.com, mjg59@google.com, phcoder@gmail.com, pirot.krol@3mdeb.com, pjones@redhat.com, ross.philipson@oracle.com Subject: [GRUB PATCH RFC 11/18] efi: Add a function to read EFI variables with attributes Date: Tue, 5 May 2020 01:21:25 +0200 Message-Id: <20200504232132.23570-12-daniel.kiper@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200504232132.23570-1-daniel.kiper@oracle.com> References: <20200504232132.23570-1-daniel.kiper@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=2 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005040182 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=2 mlxscore=0 spamscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005040181 Received-SPF: pass client-ip=156.151.31.85; envelope-from=daniel.kiper@oracle.com; helo=userp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/04 19:22:16 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 May 2020 23:23:01 -0000 It will be used to properly detect and report UEFI Secure Boot status to the x86 Linux kernel. The functionality will be added by subsequent patches. Signed-off-by: Ignat Korchagin Signed-off-by: Daniel Kiper --- grub-core/kern/efi/efi.c | 16 +++++++++++++--- include/grub/efi/efi.h | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 81bc49f84..7eeac6019 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -223,8 +223,11 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, } grub_efi_status_t -grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - grub_size_t *datasize_out, void **data_out) +grub_efi_get_variable_with_attributes (const char *var, + const grub_efi_guid_t *guid, + grub_size_t *datasize_out, + void **data_out, + grub_efi_uint32_t *attributes) { grub_efi_status_t status; grub_efi_uintn_t datasize = 0; @@ -261,7 +264,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, return GRUB_EFI_OUT_OF_RESOURCES; } - status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data); + status = efi_call_5 (r->get_variable, var16, guid, attributes, &datasize, data); grub_free (var16); if (status == GRUB_EFI_SUCCESS) @@ -275,6 +278,13 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, return status; } +grub_efi_status_t +grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + grub_size_t *datasize_out, void **data_out) +{ + return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL); +} + #pragma GCC diagnostic ignored "-Wcast-align" /* Search the mods section from the PE32/PE32+ image. This code uses diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 8b2a0f1f5..83d958f99 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -74,6 +74,11 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo grub_efi_uintn_t descriptor_size, grub_efi_uint32_t descriptor_version, grub_efi_memory_descriptor_t *virtual_map); +grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable, + const grub_efi_guid_t *guid, + grub_size_t *datasize_out, + void **data_out, + grub_efi_uint32_t *attributes); grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable, const grub_efi_guid_t *guid, grub_size_t *datasize_out, -- 2.11.0