diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-04-30 06:30:24 -0400 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-04-30 06:42:13 -0400 |
commit | a614e1923d5389d01f3545ee4a90e39a04d0c90d (patch) | |
tree | e8e32dba12a66ffd26d78f015a142ac28e19ad8e /drivers/firmware | |
parent | f53f292eeaa234615c31a1306babe703fc4263f2 (diff) | |
parent | c1be5a5b1b355d40e6cf79cc979eb66dafa24ad1 (diff) |
Merge tag 'v3.9' into efi-for-tip2
Resolve conflicts for Ingo.
Conflicts:
drivers/firmware/Kconfig
drivers/firmware/efivars.c
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/efi/efi-pstore.c | 11 | ||||
-rw-r--r-- | drivers/firmware/efi/efi.c | 2 | ||||
-rw-r--r-- | drivers/firmware/efi/efivars.c | 3 | ||||
-rw-r--r-- | drivers/firmware/efi/vars.c | 37 | ||||
-rw-r--r-- | drivers/firmware/google/gsmi.c | 9 |
5 files changed, 27 insertions, 35 deletions
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index 47ae712c9504..221ad1bf94de 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <linux/efi.h> | 1 | #include <linux/efi.h> |
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/pstore.h> | 3 | #include <linux/pstore.h> |
4 | #include <linux/ucs2_string.h> | ||
4 | 5 | ||
5 | #define DUMP_NAME_LEN 52 | 6 | #define DUMP_NAME_LEN 52 |
6 | 7 | ||
@@ -140,15 +141,15 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) | |||
140 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; | 141 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; |
141 | efi_char16_t efi_name_old[DUMP_NAME_LEN]; | 142 | efi_char16_t efi_name_old[DUMP_NAME_LEN]; |
142 | efi_char16_t *efi_name = ed->name; | 143 | efi_char16_t *efi_name = ed->name; |
143 | unsigned long utf16_len = utf16_strlen(ed->name); | 144 | unsigned long ucs2_len = ucs2_strlen(ed->name); |
144 | char name_old[DUMP_NAME_LEN]; | 145 | char name_old[DUMP_NAME_LEN]; |
145 | int i; | 146 | int i; |
146 | 147 | ||
147 | if (efi_guidcmp(entry->var.VendorGuid, vendor)) | 148 | if (efi_guidcmp(entry->var.VendorGuid, vendor)) |
148 | return 0; | 149 | return 0; |
149 | 150 | ||
150 | if (utf16_strncmp(entry->var.VariableName, | 151 | if (ucs2_strncmp(entry->var.VariableName, |
151 | efi_name, (size_t)utf16_len)) { | 152 | efi_name, (size_t)ucs2_len)) { |
152 | /* | 153 | /* |
153 | * Check if an old format, which doesn't support | 154 | * Check if an old format, which doesn't support |
154 | * holding multiple logs, remains. | 155 | * holding multiple logs, remains. |
@@ -159,8 +160,8 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data) | |||
159 | for (i = 0; i < DUMP_NAME_LEN; i++) | 160 | for (i = 0; i < DUMP_NAME_LEN; i++) |
160 | efi_name_old[i] = name_old[i]; | 161 | efi_name_old[i] = name_old[i]; |
161 | 162 | ||
162 | if (utf16_strncmp(entry->var.VariableName, efi_name_old, | 163 | if (ucs2_strncmp(entry->var.VariableName, efi_name_old, |
163 | utf16_strlen(efi_name_old))) | 164 | ucs2_strlen(efi_name_old))) |
164 | return 0; | 165 | return 0; |
165 | } | 166 | } |
166 | 167 | ||
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 32bdf4f8e432..5145fa344ad5 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -72,7 +72,7 @@ static int generic_ops_register(void) | |||
72 | generic_ops.get_variable = efi.get_variable; | 72 | generic_ops.get_variable = efi.get_variable; |
73 | generic_ops.set_variable = efi.set_variable; | 73 | generic_ops.set_variable = efi.set_variable; |
74 | generic_ops.get_next_variable = efi.get_next_variable; | 74 | generic_ops.get_next_variable = efi.get_next_variable; |
75 | generic_ops.query_variable_info = efi.query_variable_info; | 75 | generic_ops.query_variable_store = efi_query_variable_store; |
76 | 76 | ||
77 | return efivars_register(&generic_efivars, &generic_ops, efi_kobj); | 77 | return efivars_register(&generic_efivars, &generic_ops, efi_kobj); |
78 | } | 78 | } |
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 70635b3b59d3..f8f5e5d9e020 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c | |||
@@ -67,6 +67,7 @@ | |||
67 | 67 | ||
68 | #include <linux/efi.h> | 68 | #include <linux/efi.h> |
69 | #include <linux/module.h> | 69 | #include <linux/module.h> |
70 | #include <linux/ucs2_string.h> | ||
70 | 71 | ||
71 | #define EFIVARS_VERSION "0.08" | 72 | #define EFIVARS_VERSION "0.08" |
72 | #define EFIVARS_DATE "2004-May-17" | 73 | #define EFIVARS_DATE "2004-May-17" |
@@ -407,7 +408,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var) | |||
407 | efi_char16_t *variable_name; | 408 | efi_char16_t *variable_name; |
408 | 409 | ||
409 | variable_name = new_var->var.VariableName; | 410 | variable_name = new_var->var.VariableName; |
410 | variable_name_size = utf16_strlen(variable_name) * sizeof(efi_char16_t); | 411 | variable_name_size = ucs2_strlen(variable_name) * sizeof(efi_char16_t); |
411 | 412 | ||
412 | /* | 413 | /* |
413 | * Length of the variable bytes in ASCII, plus the '-' separator, | 414 | * Length of the variable bytes in ASCII, plus the '-' separator, |
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index dd1c20a426fa..1d80c1ca39c5 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/device.h> | 32 | #include <linux/device.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <linux/ctype.h> | 34 | #include <linux/ctype.h> |
35 | #include <linux/ucs2_string.h> | ||
35 | 36 | ||
36 | /* Private pointer to registered efivars */ | 37 | /* Private pointer to registered efivars */ |
37 | static struct efivars *__efivars; | 38 | static struct efivars *__efivars; |
@@ -91,7 +92,7 @@ validate_load_option(struct efi_variable *var, int match, u8 *buffer, | |||
91 | u16 filepathlength; | 92 | u16 filepathlength; |
92 | int i, desclength = 0, namelen; | 93 | int i, desclength = 0, namelen; |
93 | 94 | ||
94 | namelen = utf16_strnlen(var->VariableName, sizeof(var->VariableName)); | 95 | namelen = ucs2_strnlen(var->VariableName, sizeof(var->VariableName)); |
95 | 96 | ||
96 | /* Either "Boot" or "Driver" followed by four digits of hex */ | 97 | /* Either "Boot" or "Driver" followed by four digits of hex */ |
97 | for (i = match; i < match+4; i++) { | 98 | for (i = match; i < match+4; i++) { |
@@ -114,7 +115,7 @@ validate_load_option(struct efi_variable *var, int match, u8 *buffer, | |||
114 | * There's no stored length for the description, so it has to be | 115 | * There's no stored length for the description, so it has to be |
115 | * found by hand | 116 | * found by hand |
116 | */ | 117 | */ |
117 | desclength = utf16_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2; | 118 | desclength = ucs2_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2; |
118 | 119 | ||
119 | /* Each boot entry must have a descriptor */ | 120 | /* Each boot entry must have a descriptor */ |
120 | if (!desclength) | 121 | if (!desclength) |
@@ -228,24 +229,12 @@ EXPORT_SYMBOL_GPL(efivar_validate); | |||
228 | static efi_status_t | 229 | static efi_status_t |
229 | check_var_size(u32 attributes, unsigned long size) | 230 | check_var_size(u32 attributes, unsigned long size) |
230 | { | 231 | { |
231 | u64 storage_size, remaining_size, max_size; | ||
232 | efi_status_t status; | ||
233 | const struct efivar_operations *fops = __efivars->ops; | 232 | const struct efivar_operations *fops = __efivars->ops; |
234 | 233 | ||
235 | if (!fops->query_variable_info) | 234 | if (!fops->query_variable_store) |
236 | return EFI_UNSUPPORTED; | 235 | return EFI_UNSUPPORTED; |
237 | 236 | ||
238 | status = fops->query_variable_info(attributes, &storage_size, | 237 | return fops->query_variable_store(attributes, size); |
239 | &remaining_size, &max_size); | ||
240 | |||
241 | if (status != EFI_SUCCESS) | ||
242 | return status; | ||
243 | |||
244 | if (!storage_size || size > remaining_size || size > max_size || | ||
245 | (remaining_size - size) < (storage_size / 2)) | ||
246 | return EFI_OUT_OF_RESOURCES; | ||
247 | |||
248 | return status; | ||
249 | } | 238 | } |
250 | 239 | ||
251 | static int efi_status_to_err(efi_status_t status) | 240 | static int efi_status_to_err(efi_status_t status) |
@@ -288,9 +277,9 @@ static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, | |||
288 | unsigned long strsize1, strsize2; | 277 | unsigned long strsize1, strsize2; |
289 | bool found = false; | 278 | bool found = false; |
290 | 279 | ||
291 | strsize1 = utf16_strsize(variable_name, 1024); | 280 | strsize1 = ucs2_strsize(variable_name, 1024); |
292 | list_for_each_entry_safe(entry, n, head, list) { | 281 | list_for_each_entry_safe(entry, n, head, list) { |
293 | strsize2 = utf16_strsize(entry->var.VariableName, 1024); | 282 | strsize2 = ucs2_strsize(entry->var.VariableName, 1024); |
294 | if (strsize1 == strsize2 && | 283 | if (strsize1 == strsize2 && |
295 | !memcmp(variable_name, &(entry->var.VariableName), | 284 | !memcmp(variable_name, &(entry->var.VariableName), |
296 | strsize2) && | 285 | strsize2) && |
@@ -594,7 +583,7 @@ int efivar_entry_set(struct efivar_entry *entry, u32 attributes, | |||
594 | return -EEXIST; | 583 | return -EEXIST; |
595 | } | 584 | } |
596 | 585 | ||
597 | status = check_var_size(attributes, size + utf16_strsize(name, 1024)); | 586 | status = check_var_size(attributes, size + ucs2_strsize(name, 1024)); |
598 | if (status == EFI_SUCCESS || status == EFI_UNSUPPORTED) | 587 | if (status == EFI_SUCCESS || status == EFI_UNSUPPORTED) |
599 | status = ops->set_variable(name, &vendor, | 588 | status = ops->set_variable(name, &vendor, |
600 | attributes, size, data); | 589 | attributes, size, data); |
@@ -630,7 +619,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, | |||
630 | unsigned long flags; | 619 | unsigned long flags; |
631 | efi_status_t status; | 620 | efi_status_t status; |
632 | 621 | ||
633 | if (!ops->query_variable_info) | 622 | if (!ops->query_variable_store) |
634 | return -ENOSYS; | 623 | return -ENOSYS; |
635 | 624 | ||
636 | if (!block && spin_trylock_irqsave(&__efivars->lock, flags)) | 625 | if (!block && spin_trylock_irqsave(&__efivars->lock, flags)) |
@@ -638,7 +627,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, | |||
638 | else | 627 | else |
639 | spin_lock_irqsave(&__efivars->lock, flags); | 628 | spin_lock_irqsave(&__efivars->lock, flags); |
640 | 629 | ||
641 | status = check_var_size(attributes, size + utf16_strsize(name, 1024)); | 630 | status = check_var_size(attributes, size + ucs2_strsize(name, 1024)); |
642 | if (status != EFI_SUCCESS) { | 631 | if (status != EFI_SUCCESS) { |
643 | spin_unlock_irqrestore(&__efivars->lock, flags); | 632 | spin_unlock_irqrestore(&__efivars->lock, flags); |
644 | return -ENOSPC; | 633 | return -ENOSPC; |
@@ -679,8 +668,8 @@ struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, | |||
679 | WARN_ON(!spin_is_locked(&__efivars->lock)); | 668 | WARN_ON(!spin_is_locked(&__efivars->lock)); |
680 | 669 | ||
681 | list_for_each_entry_safe(entry, n, head, list) { | 670 | list_for_each_entry_safe(entry, n, head, list) { |
682 | strsize1 = utf16_strsize(name, 1024); | 671 | strsize1 = ucs2_strsize(name, 1024); |
683 | strsize2 = utf16_strsize(entry->var.VariableName, 1024); | 672 | strsize2 = ucs2_strsize(entry->var.VariableName, 1024); |
684 | if (strsize1 == strsize2 && | 673 | if (strsize1 == strsize2 && |
685 | !memcmp(name, &(entry->var.VariableName), strsize1) && | 674 | !memcmp(name, &(entry->var.VariableName), strsize1) && |
686 | !efi_guidcmp(guid, entry->var.VendorGuid)) { | 675 | !efi_guidcmp(guid, entry->var.VendorGuid)) { |
@@ -818,7 +807,7 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes, | |||
818 | /* | 807 | /* |
819 | * Ensure that the available space hasn't shrunk below the safe level | 808 | * Ensure that the available space hasn't shrunk below the safe level |
820 | */ | 809 | */ |
821 | status = check_var_size(attributes, *size + utf16_strsize(name, 1024)); | 810 | status = check_var_size(attributes, *size + ucs2_strsize(name, 1024)); |
822 | if (status != EFI_SUCCESS) { | 811 | if (status != EFI_SUCCESS) { |
823 | if (status != EFI_UNSUPPORTED) { | 812 | if (status != EFI_UNSUPPORTED) { |
824 | err = efi_status_to_err(status); | 813 | err = efi_status_to_err(status); |
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 757b2d92d5b0..acba0b9f4406 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/reboot.h> | 28 | #include <linux/reboot.h> |
29 | #include <linux/efi.h> | 29 | #include <linux/efi.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/ucs2_string.h> | ||
31 | 32 | ||
32 | #define GSMI_SHUTDOWN_CLEAN 0 /* Clean Shutdown */ | 33 | #define GSMI_SHUTDOWN_CLEAN 0 /* Clean Shutdown */ |
33 | /* TODO(mikew@google.com): Tie in HARDLOCKUP_DETECTOR with NMIWDT */ | 34 | /* TODO(mikew@google.com): Tie in HARDLOCKUP_DETECTOR with NMIWDT */ |
@@ -300,7 +301,7 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name, | |||
300 | }; | 301 | }; |
301 | efi_status_t ret = EFI_SUCCESS; | 302 | efi_status_t ret = EFI_SUCCESS; |
302 | unsigned long flags; | 303 | unsigned long flags; |
303 | size_t name_len = utf16_strnlen(name, GSMI_BUF_SIZE / 2); | 304 | size_t name_len = ucs2_strnlen(name, GSMI_BUF_SIZE / 2); |
304 | int rc; | 305 | int rc; |
305 | 306 | ||
306 | if (name_len >= GSMI_BUF_SIZE / 2) | 307 | if (name_len >= GSMI_BUF_SIZE / 2) |
@@ -369,7 +370,7 @@ static efi_status_t gsmi_get_next_variable(unsigned long *name_size, | |||
369 | return EFI_BAD_BUFFER_SIZE; | 370 | return EFI_BAD_BUFFER_SIZE; |
370 | 371 | ||
371 | /* Let's make sure the thing is at least null-terminated */ | 372 | /* Let's make sure the thing is at least null-terminated */ |
372 | if (utf16_strnlen(name, GSMI_BUF_SIZE / 2) == GSMI_BUF_SIZE / 2) | 373 | if (ucs2_strnlen(name, GSMI_BUF_SIZE / 2) == GSMI_BUF_SIZE / 2) |
373 | return EFI_INVALID_PARAMETER; | 374 | return EFI_INVALID_PARAMETER; |
374 | 375 | ||
375 | spin_lock_irqsave(&gsmi_dev.lock, flags); | 376 | spin_lock_irqsave(&gsmi_dev.lock, flags); |
@@ -397,7 +398,7 @@ static efi_status_t gsmi_get_next_variable(unsigned long *name_size, | |||
397 | 398 | ||
398 | /* Copy the name back */ | 399 | /* Copy the name back */ |
399 | memcpy(name, gsmi_dev.name_buf->start, GSMI_BUF_SIZE); | 400 | memcpy(name, gsmi_dev.name_buf->start, GSMI_BUF_SIZE); |
400 | *name_size = utf16_strnlen(name, GSMI_BUF_SIZE / 2) * 2; | 401 | *name_size = ucs2_strnlen(name, GSMI_BUF_SIZE / 2) * 2; |
401 | 402 | ||
402 | /* copy guid to return buffer */ | 403 | /* copy guid to return buffer */ |
403 | memcpy(vendor, ¶m.guid, sizeof(param.guid)); | 404 | memcpy(vendor, ¶m.guid, sizeof(param.guid)); |
@@ -423,7 +424,7 @@ static efi_status_t gsmi_set_variable(efi_char16_t *name, | |||
423 | EFI_VARIABLE_BOOTSERVICE_ACCESS | | 424 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
424 | EFI_VARIABLE_RUNTIME_ACCESS, | 425 | EFI_VARIABLE_RUNTIME_ACCESS, |
425 | }; | 426 | }; |
426 | size_t name_len = utf16_strnlen(name, GSMI_BUF_SIZE / 2); | 427 | size_t name_len = ucs2_strnlen(name, GSMI_BUF_SIZE / 2); |
427 | efi_status_t ret = EFI_SUCCESS; | 428 | efi_status_t ret = EFI_SUCCESS; |
428 | int rc; | 429 | int rc; |
429 | unsigned long flags; | 430 | unsigned long flags; |