Skip to contentSkip to conversation

Add missing attributes to EFI variable attribute print out from sysfs

PATCH Superseded Khalid Aziz 3 participants 8 messages Jul 13, 2012 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add missing attributes to EFI variable attribute print out from sysfs

Some of the EFI variable attributes are missing from print out from /sys/firmware/efi/vars/*/attributes. This patch adds those in.

---
 drivers/firmware/efivars.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/firmware/efivars.c +10 -0
index 47408e8..1e1ac75 100644
@@ -441,6 +441,16 @@ efivar_attr_read(struct efivar_entry *entry, char *buf)
 		str += sprintf(str, "EFI_VARIABLE_BOOTSERVICE_ACCESS\n");
 	if (var->Attributes & 0x4)
 		str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");
+	if (var->Attributes & 0x8)
+		str += sprintf(str, "EFI_VARIABLE_HARDWARE_ERROR_RECORD\n");
+	if (var->Attributes & 0x10)
+		str += sprintf(str,
+			"EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\n");
+	if (var->Attributes & 0x20)
+		str += sprintf(str,
+			"EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\n");
+	if (var->Attributes & 0x40)
+		str += sprintf(str, "EFI_VARIABLE_APPEND_WRITE\n");
 	return str - buf;
 }
 
Signature · 5 lines
1.7.9.5

==================
Khalid Aziz
[email protected]
#2 lore raw
In reply to Khalid Aziz

drivers/firmware/efivars.c efivar_attr_read(struct efivar_entry *entry, char *buf) · line 443

Quoted 2 lines · Khalid Aziz
drivers/firmware/efivars.c +0 -0
 	if (var->Attributes & 0x4)
 		str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");

I know you're just following the pattern of the existing code, but could you change these to be more like

if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)

while you're at it? I think that'd be a worthwhile cleanup.

Signature · 1 line
Matthew Garrett | [email protected]
#3 lore raw
Quoted 10 lines · Matthew Garrett
Quoted 2 lines · Khalid Aziz
  	if (var->Attributes & 0x4)
  		str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");

I know you're just following the pattern of the existing code, but could you change these to be more like

if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)

while you're at it? I think that'd be a worthwhile cleanup.

That is a good suggestion. I will make the changes and send out updated version.

Signature · 2 lines
Khalid Aziz
[email protected]
#4 lore raw
In reply to Matthew Garrett
Quoted 7 lines · Matthew Garrett

I know you're just following the pattern of the existing code, but could you change these to be more like

if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)

while you're at it? I think that'd be a worthwhile cleanup.

I just sent out an updated patch with this change. The constant names for EFI variable attribute are pretty darn long and cause line wrap fairly quickly. I would like to rename those constants from EFI_VARIABLE_* to EFI_VAR_* and possibly shorten the overall name as well:

EFI_VARIABLE_NON_VOLATILE -> EFI_VAR_NV
EFI_VARIABLE_BOOTSERVICE_ACCESS -> EFI_VAR_BOOT
EFI_VARIABLE_RUNTIME_ACCESS -> EFI_VAR_RUNTIME
EFI_VARIABLE_HARDWARE_ERROR_RECORD -> EFI_VAR_HW_ERROR
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_AUTH_WRITE
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_TIMED_AUTH_WRITE
EFI_VARIABLE_APPEND_WRITE -> EFI_VAR_APPEND

Sounds reasonable?

Signature · 2 lines
Khalid Aziz
[email protected]
#5 lore raw
Quoted 9 lines · Khalid Aziz

EFI_VARIABLE_NON_VOLATILE -> EFI_VAR_NV
EFI_VARIABLE_BOOTSERVICE_ACCESS -> EFI_VAR_BOOT
EFI_VARIABLE_RUNTIME_ACCESS -> EFI_VAR_RUNTIME
EFI_VARIABLE_HARDWARE_ERROR_RECORD -> EFI_VAR_HW_ERROR
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_AUTH_WRITE
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_TIMED_AUTH_WRITE
EFI_VARIABLE_APPEND_WRITE -> EFI_VAR_APPEND

Sounds reasonable?

Sounds great, but sadly they're exposed to userspace so changing them would be a problem. Adding aliases would be ugly but workable?

Signature · 1 line
Matthew Garrett | [email protected]
#6 lore raw
Quoted 9 lines · Matthew Garrett
Quoted 8 lines · Khalid Aziz

EFI_VARIABLE_NON_VOLATILE -> EFI_VAR_NV
EFI_VARIABLE_BOOTSERVICE_ACCESS -> EFI_VAR_BOOT
EFI_VARIABLE_RUNTIME_ACCESS -> EFI_VAR_RUNTIME
EFI_VARIABLE_HARDWARE_ERROR_RECORD -> EFI_VAR_HW_ERROR
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_AUTH_WRITE
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_TIMED_AUTH_WRITE
EFI_VARIABLE_APPEND_WRITE -> EFI_VAR_APPEND

Quoted 4 lines
Quoted 1 line

Sounds reasonable?

Sounds great, but sadly they're exposed to userspace so changing them would be a problem. Adding aliases would be ugly but workable?

Ugly but practical. I agree with creating alias. I can work up a patch that creates the aliases in efi.h, and replaces all uses in kernel with shorter names. This does not change ABI or API, so existing userspace programs will continue to work.

Signature · 2 lines
Khalid Aziz
[email protected]

A message that is not in the archive (sent off-list or not yet received): CAGTjWtA0LmQ-90zjYf0nho_LEra8nx32M1R7E6o=3S68UjfEHw@mail.gmail.com

#8 lore raw
Quoted 1 line · Mike Waychison

You can probably save the wrap by copying out var->Attributes into a local.

Yes, you are right. It will work in this case. I am considering the general case of very long name for a constant causing issues with line wrap in more complex code, or just plain being a pain to type such a long name (one of these constants is ~50 characters).

--
Khalid Aziz
[email protected]