Hello Furquan Shaikh, Arthur Heymans, Kyösti Mälkki, Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/41553
to review the following change.
Change subject: device/pci: Don't enabled unassigned resources
......................................................................
device/pci: Don't enabled unassigned resources
We only have a single bit in the PCI_COMMAND register to enable
or disable resources of one type. If any resource of a type is
unassigned, we have to disable all of them.
Change-Id: I7a7e9c5c382358446b60a7bd5b29954f80cce07e
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M src/device/pci_device.c
1 file changed, 12 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/53/41553/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 5afbfa9..8df44df 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -506,7 +506,8 @@
}
}
-static void pci_set_resource(struct device *dev, struct resource *resource)
+static void pci_set_resource(struct device *const dev, struct resource *const resource,
+ uint16_t *const command_mask)
{
/* Make certain the resource has actually been assigned a value. */
if (!(resource->flags & IORESOURCE_ASSIGNED)) {
@@ -518,6 +519,11 @@
printk(BIOS_ERR, "ERROR: %s %02lx %s size: 0x%010llx not "
"assigned\n", dev_path(dev), resource->index,
resource_type(resource), resource->size);
+ /* We'll have to disable all resources of this type. */
+ if (resource->flags & IORESOURCE_MEM)
+ *command_mask &= ~PCI_COMMAND_MEMORY;
+ if (resource->flags & IORESOURCE_IO)
+ *command_mask &= ~PCI_COMMAND_IO;
return;
}
}
@@ -561,12 +567,16 @@
void pci_dev_set_resources(struct device *dev)
{
+ uint16_t command_mask = 0xffff;
struct resource *res;
struct bus *bus;
u8 line;
for (res = dev->resource_list; res; res = res->next)
- pci_set_resource(dev, res);
+ pci_set_resource(dev, res, &command_mask);
+ /* If there are unassigned resources, we might
+ have to disable others of the same type. */
+ dev->command &= command_mask;
for (bus = dev->link_list; bus; bus = bus->next) {
if (bus->children)
--
To view, visit https://review.coreboot.org/c/coreboot/+/41553
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7a7e9c5c382358446b60a7bd5b29954f80cce07e
Gerrit-Change-Number: 41553
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com>
Gerrit-Reviewer: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/47016 )
Change subject: cpu/x86/smm: Add a function for the amount of support CPUs
......................................................................
cpu/x86/smm: Add a function for the amount of support CPUs
CONFIG_MAX_CPUS might be larger than the amount for which an SMI
handler is installed. So when looping over CONFIG_MAX_CPUS to fetch a
SMM save state one might access memory that does not belong to a CPU
node save state and get invalid results.
Change-Id: Ibc17602aa2817d910292c37d0a0095d3d9dc0aae
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/cpu/amd/smm/amd64_save_state.c
M src/cpu/intel/smm/em64t100_save_state.c
M src/cpu/intel/smm/em64t101_save_state.c
M src/cpu/x86/smm/legacy_save_state.c
M src/cpu/x86/smm/save_state.c
M src/cpu/x86/smm/smihandler.c
M src/cpu/x86/smm/smm_module_handler.c
M src/include/cpu/x86/smm.h
8 files changed, 20 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/16/47016/1
diff --git a/src/cpu/amd/smm/amd64_save_state.c b/src/cpu/amd/smm/amd64_save_state.c
index db329c0..a274fd1 100644
--- a/src/cpu/amd/smm/amd64_save_state.c
+++ b/src/cpu/amd/smm/amd64_save_state.c
@@ -84,7 +84,7 @@
int node;
u8 reg_al;
- for (node = 0; node < CONFIG_MAX_CPUS; node++) {
+ for (node = 0; node < smm_max_cpus(); node++) {
state = smm_get_save_state(node);
smm_io_trap = state->smm_io_trap_offset;
diff --git a/src/cpu/intel/smm/em64t100_save_state.c b/src/cpu/intel/smm/em64t100_save_state.c
index 4fd7d76..fe5f65e 100644
--- a/src/cpu/intel/smm/em64t100_save_state.c
+++ b/src/cpu/intel/smm/em64t100_save_state.c
@@ -72,7 +72,7 @@
em64t100_smm_state_save_area_t *state;
int node;
- for (node = 0; node < CONFIG_MAX_CPUS; node++) {
+ for (node = 0; node < smm_max_cpus(); node++) {
state = smm_get_save_state(node);
/* Check for Synchronous IO (bit0 == 1) */
diff --git a/src/cpu/intel/smm/em64t101_save_state.c b/src/cpu/intel/smm/em64t101_save_state.c
index c6aa397..70112df 100644
--- a/src/cpu/intel/smm/em64t101_save_state.c
+++ b/src/cpu/intel/smm/em64t101_save_state.c
@@ -72,7 +72,7 @@
em64t101_smm_state_save_area_t *state;
int node;
- for (node = 0; node < CONFIG_MAX_CPUS; node++) {
+ for (node = 0; node < smm_max_cpus(); node++) {
state = smm_get_save_state(node);
/* Check for Synchronous IO (bit0 == 1) */
diff --git a/src/cpu/x86/smm/legacy_save_state.c b/src/cpu/x86/smm/legacy_save_state.c
index 8e996ee..0b07155 100644
--- a/src/cpu/x86/smm/legacy_save_state.c
+++ b/src/cpu/x86/smm/legacy_save_state.c
@@ -71,7 +71,7 @@
legacy_smm_state_save_area_t *state;
int node;
- for (node = 0; node < CONFIG_MAX_CPUS; node++) {
+ for (node = 0; node < smm_max_cpus(); node++) {
state = smm_get_save_state(node);
/* Check AL against the requested command */
diff --git a/src/cpu/x86/smm/save_state.c b/src/cpu/x86/smm/save_state.c
index bb08f86..c860b03 100644
--- a/src/cpu/x86/smm/save_state.c
+++ b/src/cpu/x86/smm/save_state.c
@@ -59,7 +59,7 @@
if (init_save_state())
return -1;
- if (node > CONFIG_MAX_CPUS)
+ if (node > smm_max_cpus())
return -1;
return save_state->get_reg(reg, node, out, length);
@@ -70,7 +70,7 @@
if (init_save_state())
return -1;
- if (node > CONFIG_MAX_CPUS)
+ if (node > smm_max_cpus())
return -1;
return save_state->set_reg(reg, node, in, length);
diff --git a/src/cpu/x86/smm/smihandler.c b/src/cpu/x86/smm/smihandler.c
index 0d9131e..21b2b5e 100644
--- a/src/cpu/x86/smm/smihandler.c
+++ b/src/cpu/x86/smm/smihandler.c
@@ -136,6 +136,11 @@
return region_overlap(&r_smm, r);
}
+uint32_t smm_max_cpus(void)
+{
+ return CONFIG_MAX_CPUS;
+}
+
/**
* @brief Interrupt handler for SMI#
*
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c
index 3ba5684..89864c4 100644
--- a/src/cpu/x86/smm/smm_module_handler.c
+++ b/src/cpu/x86/smm/smm_module_handler.c
@@ -119,6 +119,11 @@
return region_overlap(&r_smm, r) || region_overlap(&r_aseg, r);
}
+uint32_t smm_max_cpus(void)
+{
+ return MIN(smm_runtime->num_cpus, CONFIG_MAX_CPUS);
+}
+
asmlinkage void smm_handler_start(void *arg)
{
const struct smm_module_params *p;
@@ -137,7 +142,7 @@
if (smm_runtime == NULL)
smm_runtime = runtime;
- if (cpu >= CONFIG_MAX_CPUS) {
+ if (cpu >= smm_max_cpus()) {
console_init();
printk(BIOS_CRIT,
"Invalid CPU number assigned in SMM stub: %d\n", cpu);
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index 6cf6f82..8bdd695 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -98,6 +98,9 @@
* account CPUs which are configured to not save their state to RAM. */
void *smm_get_save_state(int cpu);
+/* Return the amount of CPUs the smihandler is set up to handle. */
+uint32_t smm_max_cpus(void);
+
/* Returns true if the region overlaps with the SMM */
bool smm_region_overlaps_handler(const struct region *r);
--
To view, visit https://review.coreboot.org/c/coreboot/+/47016
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ibc17602aa2817d910292c37d0a0095d3d9dc0aae
Gerrit-Change-Number: 47016
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-MessageType: newchange
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46730 )
Change subject: [RFC] libpayload/keyboard: Dynamically toggle controller translation
......................................................................
[RFC] libpayload/keyboard: Dynamically toggle controller translation
This is what would be necessary to detect cases where we have to
toggle the keyboard controller's scancode translation.
After setting the matching scancode set for the current translation
setting, we read it back and try to adapt the translation setting
of necessary.
It adds a lot complexity, so we'd probably want to avoid it? Chances
that we find a keyboard that can't switch scancode sets and isn't
integrated (where we could set the correct translation setting in
coreboot) seem rather low.
Change-Id: I938184875e1c4c40cdb2762e1c5b6ed9c8f82b90
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M payloads/libpayload/drivers/i8042/i8042.c
M payloads/libpayload/drivers/i8042/i8042.h
M payloads/libpayload/drivers/i8042/keyboard.c
3 files changed, 102 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/46730/1
diff --git a/payloads/libpayload/drivers/i8042/i8042.c b/payloads/libpayload/drivers/i8042/i8042.c
index 317d04b..487863e 100644
--- a/payloads/libpayload/drivers/i8042/i8042.c
+++ b/payloads/libpayload/drivers/i8042/i8042.c
@@ -317,6 +317,24 @@
}
/**
+ * Send command & data to keyboard controller.
+ *
+ * @param cmd: The command to be send.
+ * @param data: The data to be send.
+ * Returns 0 on success, -1 on failure.
+ */
+int i8042_cmd_with_data(const u8 cmd, const u8 data)
+{
+ const int ret = i8042_cmd(cmd);
+ if (ret != 0)
+ return ret;
+
+ i8042_write_data(data);
+
+ return ret;
+}
+
+/**
* Probe for keyboard controller data and queue it.
*/
static void i8042_data_poll(void)
diff --git a/payloads/libpayload/drivers/i8042/i8042.h b/payloads/libpayload/drivers/i8042/i8042.h
index 68fd149..f2dc0d0 100644
--- a/payloads/libpayload/drivers/i8042/i8042.h
+++ b/payloads/libpayload/drivers/i8042/i8042.h
@@ -29,6 +29,8 @@
#ifndef __DRIVERS_I8042_I8042_H__
#define __DRIVERS_I8042_I8042_H__
+#include <stdint.h>
+
/* Port 0x64 commands */
#define I8042_CMD_RD_CMD_BYTE 0x20
#define I8042_CMD_WR_CMD_BYTE 0x60
@@ -67,5 +69,6 @@
#define I8042_KBCMD_RESET 0xff
int i8042_cmd_with_response(u8 cmd);
+int i8042_cmd_with_data(u8 cmd, u8 data);
#endif /* __DRIVERS_I8042_I8042_H__ */
diff --git a/payloads/libpayload/drivers/i8042/keyboard.c b/payloads/libpayload/drivers/i8042/keyboard.c
index aa21b9d..c3cba9b 100644
--- a/payloads/libpayload/drivers/i8042/keyboard.c
+++ b/payloads/libpayload/drivers/i8042/keyboard.c
@@ -27,6 +27,7 @@
* SUCH DAMAGE.
*/
+#include <assert.h>
#include <stdbool.h>
#include <keycodes.h>
@@ -326,27 +327,90 @@
return ctrl_cfg < 0 || (ctrl_cfg & I8042_CMD_BYTE_XLATE);
}
-/* Set scancode set 1 */
-static bool set_scancode_set(const unsigned char set)
+static bool send_scancode_set(const unsigned char set)
{
- bool ret;
+ assert(set <= 3);
- if (set < 1 || set > 3)
+ if (!keyboard_cmd(I8042_KBCMD_SET_SCANCODE) ||
+ !keyboard_cmd(set)) {
+ printf("ERROR: Keyboard send scancode set#%u failed!\n", set);
+ return false;
+ }
+ return true;
+}
+
+static unsigned char select_scancode_set(const bool xlate)
+{
+ /*
+ * We only support scancode set 1. The controller translation
+ * would translate from set 2 to 1 for us, so we try to configure:
+ *
+ * o set 1 if the controller doesn't translate, and
+ * o set 2 if the controller does.
+ */
+ const unsigned char set = xlate ? 2 : 1;
+
+ if (!send_scancode_set(set))
+ return 2;
+
+ /*
+ * Now try to confirm the current scancode set selection.
+ */
+ if (!send_scancode_set(0)) /* retrieve current scancode set # */
+ return 2;
+
+ int actual_set = i8042_wait_read_ps2();
+ if (xlate) {
+ /* controllers translate even this answer */
+ switch (actual_set) {
+ case 0x43: actual_set = 1; break;
+ case 0x41: actual_set = 2; break;
+ case 0x3f: actual_set = 3; break;
+ }
+ }
+
+ if (actual_set < 1) /* assume success on unexpected data */
+ return set;
+
+ return actual_set;
+}
+
+static bool prepare_scancode_set(void)
+{
+ const bool xlate = controller_translates();
+
+ const unsigned char set = select_scancode_set(xlate);
+
+ if (set > 2) /* We can't do anything with scancode set #3. */
return false;
- ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE);
- if (!ret) {
- printf("ERROR: Keyboard set scancode failed!\n");
- return ret;
+ if ((set != 2 && !xlate) || (set == 2 && xlate))
+ return true;
+
+ /*
+ * In case we failed to set the correct scancode set, fall back
+ * and try to change the controller's translation setting.
+ */
+ printf("WARNING: Keyboard failed to select correct scancode set.\n");
+
+ int ctrl_cfg = i8042_cmd_with_response(I8042_CMD_RD_CMD_BYTE);
+ if (ctrl_cfg < 0) {
+ printf("ERROR: i8042_cmd RD_CMD failed!\n");
+ return false;
}
- ret = keyboard_cmd(set);
- if (!ret) {
- printf("ERROR: Keyboard scancode set#%u failed!\n", set);
- return ret;
+ if (xlate)
+ ctrl_cfg &= ~I8042_CMD_BYTE_XLATE;
+ else
+ ctrl_cfg |= I8042_CMD_BYTE_XLATE;
+
+ const int ret = i8042_cmd_with_data(I8042_CMD_WR_CMD_BYTE, ctrl_cfg);
+ if (ret < 0) {
+ printf("ERROR: i8042_cmd WR_CMD failed!\n");
+ return false;
}
- return ret;
+ return true;
}
void keyboard_init(void)
@@ -364,14 +428,10 @@
/* Enable first PS/2 port */
i8042_cmd(I8042_CMD_EN_KB);
- /*
- * We only support scancode set 1. The controller translation
- * would translate from set 2 to 1 for us, so we try to configure
- *
- * o set 1 if the controller doesn't translate, and
- * o set 2 if the controller does.
- */
- (void)set_scancode_set(controller_translates() ? 2 : 1);
+ if (!prepare_scancode_set()) {
+ printf("ERROR: Keyboard failed to configure scancode set, giving up.\n");
+ return;
+ }
/* Enable scanning */
const bool ret = keyboard_cmd(I8042_KBCMD_EN);
--
To view, visit https://review.coreboot.org/c/coreboot/+/46730
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I938184875e1c4c40cdb2762e1c5b6ed9c8f82b90
Gerrit-Change-Number: 46730
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
Paul Menzel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46558 )
Change subject: mb/amd/mandolin: cereme: Use 64K instead of 0x1000 for size notation
......................................................................
mb/amd/mandolin: cereme: Use 64K instead of 0x1000 for size notation
Use the more readable size notation, which also unifies it with
Mandolin’s FMD.
Change-Id: I95c22d8d775104dc046601418bd402317dd8e676
Signed-off-by: Paul Menzel <pmenzel(a)molgen.mpg.de>
---
M src/mainboard/amd/mandolin/variants/cereme/board.fmd
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/46558/1
diff --git a/src/mainboard/amd/mandolin/variants/cereme/board.fmd b/src/mainboard/amd/mandolin/variants/cereme/board.fmd
index b55b8b5..31a0b2a 100644
--- a/src/mainboard/amd/mandolin/variants/cereme/board.fmd
+++ b/src/mainboard/amd/mandolin/variants/cereme/board.fmd
@@ -1,7 +1,7 @@
FLASH@0xFF000000 16M {
BIOS {
EC 0x20000
- RW_MRC_CACHE 0x10000
+ RW_MRC_CACHE 64K
FMAP 0x1000
COREBOOT(CBFS)
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/46558
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I95c22d8d775104dc046601418bd402317dd8e676
Gerrit-Change-Number: 46558
Gerrit-PatchSet: 1
Gerrit-Owner: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newchange
Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43483 )
Change subject: Documentation/vendorcode/eltan/security.md: Fix bugs in the guide
......................................................................
Documentation/vendorcode/eltan/security.md: Fix bugs in the guide
ELTAN verified boot seems to be using vboot 2.1 key format not vboot
1.0. Generating vboot 1.0 keys results in public key of incorrect size
(according to the verified boot implementation in vendorcode) which
results in errors during booting.
Fix the cbfstool extraction command to take account for stage file
which may have certain sections removed.
Add note about endianess of digest generated by openssl.
Signed-off-by: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Change-Id: I27cf8e3f8e22876f671092fe4d3265a98564d996
---
M Documentation/vendorcode/eltan/security.md
1 file changed, 8 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/43483/1
diff --git a/Documentation/vendorcode/eltan/security.md b/Documentation/vendorcode/eltan/security.md
index 9dd47c0..1c05cd5 100644
--- a/Documentation/vendorcode/eltan/security.md
+++ b/Documentation/vendorcode/eltan/security.md
@@ -42,7 +42,7 @@
Create private key in RSA2048 format: `openssl genrsa -F4 -out <private_key_file> 2048`
Create public key using private key:
-`futility --vb1 create <private_key_file> <public_key_file_without_extension>`
+`futility --vb21 create <private_key_file> <public_key_file_without_extension>`
The public key will be included into coreboot and used for verified boot only.
@@ -79,9 +79,15 @@
The total number of items must match `VENDORCODE_ELTAN_OEM_MANIFEST_ITEMS`.
For every part the SHA (SHA-256) must be calculated. First extract the binary from the coreboot
-image using: `cbfstool <coreboot_file_name> extract -n <cbfs_name> -f <item_binary_file_name>`
+image using: `cbfstool <coreboot_file_name> extract -n <cbfs_name> -f <item_binary_file_name> -m x86 -U`
+Note the `-m x86 -U` flags are required for correct extraction of stages. Certain stages are
+put in CBFS without certain program sections so extraction process must also remove these sections.
+
followed by: `openssl dgst -sha256 -binary -out <hash_file_name> <item_binary_file_name>`
+The SHA256 digest will be in big endian so it must be converted to little endian with:
+`< <hash_file_name> xxd -p -c1 | tac | xxd -p -r > <hash_file_name_le>`
+
Replace -sha256 with -sha512 when `VENDORCODE_ELTAN_VBOOT_USE_SHA512` is enabled.
All the hashes must be combined to a hash binary. The hashes need to be placed in the same order as
--
To view, visit https://review.coreboot.org/c/coreboot/+/43483
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I27cf8e3f8e22876f671092fe4d3265a98564d996
Gerrit-Change-Number: 43483
Gerrit-PatchSet: 1
Gerrit-Owner: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Gerrit-MessageType: newchange