diff options
| author | Claudio Carvalho <cclaudio@linux.vnet.ibm.com> | 2017-12-09 02:52:28 -0200 |
|---|---|---|
| committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-12-18 21:30:57 -0600 |
| commit | ccdbfdac637c2ddabfcc36371344cd5c6c648e1b (patch) | |
| tree | 6b18b3327db1b920321d7a23b36347d61c48ca68 /libstb/drivers | |
| parent | 21a7bd0e07f6d3c121eacb7f840857fc3f2dacaf (diff) | |
| download | talos-skiboot-ccdbfdac637c2ddabfcc36371344cd5c6c648e1b.tar.gz talos-skiboot-ccdbfdac637c2ddabfcc36371344cd5c6c648e1b.zip | |
libstb: remove stb.c and obsolete companions
This removes all the files that were replaced by secureboot.c,
trustedboot.c and cvc.c.
Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libstb/drivers')
| -rw-r--r-- | libstb/drivers/Makefile.inc | 2 | ||||
| -rw-r--r-- | libstb/drivers/romcode.c | 138 | ||||
| -rw-r--r-- | libstb/drivers/romcode.h | 24 | ||||
| -rw-r--r-- | libstb/drivers/sw_driver.c | 76 | ||||
| -rw-r--r-- | libstb/drivers/sw_driver.h | 24 |
5 files changed, 1 insertions, 263 deletions
diff --git a/libstb/drivers/Makefile.inc b/libstb/drivers/Makefile.inc index 9eaa257b..3b8ed0f8 100644 --- a/libstb/drivers/Makefile.inc +++ b/libstb/drivers/Makefile.inc @@ -4,7 +4,7 @@ DRIVERS_DIR = libstb/drivers SUBDIRS += $(DRIVERS_DIR) -DRIVERS_SRCS = romcode.c tpm_i2c_interface.c tpm_i2c_nuvoton.c sw_driver.c +DRIVERS_SRCS = tpm_i2c_interface.c tpm_i2c_nuvoton.c DRIVERS_OBJS = $(DRIVERS_SRCS:%.c=%.o) DRIVERS = $(DRIVERS_DIR)/built-in.o diff --git a/libstb/drivers/romcode.c b/libstb/drivers/romcode.c deleted file mode 100644 index ab5f1aab..00000000 --- a/libstb/drivers/romcode.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright 2013-2016 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <chip.h> -#include <xscom.h> -#include <string.h> -#include <skiboot.h> -#include "../status_codes.h" -#include "../rom.h" -#include "romcode.h" - -#define DRIVER_NAME "romcode" - -#define ROMCODE_MEMORY_SIZE (16 * 1024) -#define ROMCODE_XSCOM_ADDRESS 0x02020017 - -/* - * From the source code of the ROM code - */ -#define ROMCODE_SHA512_OFFSET 0x20 -#define ROMCODE_VERIFY_OFFSET 0x30 - -static const char *compat = "ibm,secureboot-v1"; -static void *romcode_base_addr = NULL; -static sha2_hash_t *hw_key_hash = NULL; - -/* - * Assembly interfaces to call into ROM code. - * func_ptr is the ROM code function address, followed - * by additional parameters as necessary - */ -ROM_response __cvc_verify_v1(void *func_ptr, ROM_container_raw *container, - ROM_hw_params *params); -void __cvc_sha512_v1(void *func_ptr, const uint8_t *data, size_t len, - uint8_t *digest); - -static int romcode_verify(void *container) -{ - ROM_hw_params hw_params; - ROM_response rc; - - memset(&hw_params, 0, sizeof(ROM_hw_params)); - memcpy(&hw_params.hw_key_hash, hw_key_hash, sizeof(sha2_hash_t)); - rc = __cvc_verify_v1(romcode_base_addr + ROMCODE_VERIFY_OFFSET, - (ROM_container_raw*) container, &hw_params); - if (rc != ROM_DONE) { - /* - * Verify failed. hw_params.log indicates what checking has - * failed. This will abort the boot process. - */ - prlog(PR_ERR, "ROM: %s failed (rc=%d, hw_params.log=0x%llx)\n", - __func__, rc, be64_to_cpu(hw_params.log)); - return STB_VERIFY_FAILED; - } - return 0; -} - -static void romcode_sha512(const uint8_t *data, size_t len, uint8_t *digest) -{ - memset(digest, 0, sizeof(sha2_hash_t)); - __cvc_sha512_v1(romcode_base_addr + ROMCODE_SHA512_OFFSET, - data, len, digest); -} - -static void romcode_cleanup(void) { - if (romcode_base_addr) - free(romcode_base_addr); - hw_key_hash = NULL; -} - -static struct rom_driver_ops romcode_driver = { - .name = DRIVER_NAME, - .verify = romcode_verify, - .sha512 = romcode_sha512, - .cleanup = romcode_cleanup -}; - -void romcode_probe(const struct dt_node *node) -{ - /* This xscom register has the ROM code base address */ - const uint32_t reg_addr = ROMCODE_XSCOM_ADDRESS; - uint64_t reg_data; - struct proc_chip *chip; - const char* hash_algo; - - if (!dt_node_is_compatible(node, compat)) { - prlog(PR_DEBUG, "ROM: %s node is not compatible\n", - node->name); - return; - } - /* - * secureboot-v1 defines containers with sha512 hashes - */ - hash_algo = dt_prop_get(node, "hash-algo"); - if (strcmp(hash_algo, "sha512")) { - /** - * @fwts-label ROMHashAlgorithmInvalid - * @fwts-advice Hostboot creates the ibm,secureboot node and - * the hash-algo property. Check that the ibm,secureboot node - * layout has not changed. - */ - prlog(PR_ERR, "ROM: hash-algo=%s not expected\n", hash_algo); - return; - } - hw_key_hash = (sha2_hash_t*) dt_prop_get(node, "hw-key-hash"); - romcode_base_addr = malloc(ROMCODE_MEMORY_SIZE); - assert(romcode_base_addr); - /* - * The logic that contains the ROM within the processor is implemented - * in a way that it only responds to CI (cache inhibited) operations. - * Due to performance issues we copy the verification code from the - * secure ROM to RAM and we use memcpy_from_ci to do that. - */ - chip = next_chip(NULL); - xscom_read(chip->id, reg_addr, ®_data); - memcpy_from_ci(romcode_base_addr, (void*) reg_data, - ROMCODE_MEMORY_SIZE); - /* - * Skiboot runs with IR (Instruction Relocation) & - * DR (Data Relocation) off, so there is no need to either MMIO - * the ROM code or set the memory region as executable. - * skiboot accesses the physical memory directly. Real mode. - */ - rom_set_driver(&romcode_driver); -} diff --git a/libstb/drivers/romcode.h b/libstb/drivers/romcode.h deleted file mode 100644 index 4152eaee..00000000 --- a/libstb/drivers/romcode.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2013-2016 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __ROMCODE_H -#define __ROMCODE_H - -#include <device.h> - -extern void romcode_probe(const struct dt_node *node); - -#endif /* __ROMCODE_H */ diff --git a/libstb/drivers/sw_driver.c b/libstb/drivers/sw_driver.c deleted file mode 100644 index 287dae9d..00000000 --- a/libstb/drivers/sw_driver.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2013-2016 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <chip.h> -#include <string.h> -#include <skiboot.h> -#include <libstb/mbedtls/sha512.h> -#include "../rom.h" -#include "sw_driver.h" - -static sha2_hash_t *hw_key_hash = NULL; - -static int stb_software_verify(void *container __unused) -{ - return -100; -} - -static void stb_software_sha512(const uint8_t *data, size_t len, uint8_t *digest) -{ - mbedtls_sha512_context ctx; - mbedtls_sha512_init(&ctx); - memset(digest, 0, sizeof(sha2_hash_t)); - mbedtls_sha512_starts(&ctx, 0); // SHA512 = 0 - mbedtls_sha512_update(&ctx, data, len); - mbedtls_sha512_finish(&ctx, digest); - mbedtls_sha512_free(&ctx); -} - -static void stb_software_cleanup(void) -{ - return; -} - -static struct rom_driver_ops sw_driver = { - .name = "software", - .verify = stb_software_verify, - .sha512 = stb_software_sha512, - .cleanup = stb_software_cleanup -}; - -void stb_software_probe(const struct dt_node *node) -{ - const char* hash_algo; - - if (!dt_node_is_compatible(node, "ibm,secureboot-v1-softrom")) { - return; - } - - hash_algo = dt_prop_get(node, "hash-algo"); - if (strcmp(hash_algo, "sha512")) { - /** - * @fwts-label ROMHashAlgorithmInvalid - * @fwts-advice Hostboot creates the ibm,secureboot node and - * the hash-algo property. Check that the ibm,secureboot node - * layout has not changed. - */ - prlog(PR_ERR, "ROM: hash-algo=%s not expected\n", hash_algo); - return; - } - hw_key_hash = (sha2_hash_t*) dt_prop_get(node, "hw-key-hash"); - - rom_set_driver(&sw_driver); -} diff --git a/libstb/drivers/sw_driver.h b/libstb/drivers/sw_driver.h deleted file mode 100644 index 73adabf0..00000000 --- a/libstb/drivers/sw_driver.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2013-2016 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __SW_DRIVER_H -#define __SW_DRIVER_H - -#include <device.h> - -extern void stb_software_probe(const struct dt_node *node); - -#endif /* __ROMCODE_H */ |

