Merge branch '2023-11-17-assorted-important-fixes'

- Revert HAFDBS changes, correct spl_imx_romapi for eMMC, fix the virtio
  rng in one case, fix bootstd in one case, and correct a Kconfig
  description.
This commit is contained in:
Tom Rini 2023-11-17 13:15:33 -05:00
commit cc7bc8237a
9 changed files with 25 additions and 53 deletions

View file

@ -327,7 +327,7 @@ config SPL_SYS_MALLOC_F_LEN
malloc() region in SDRAM once it is inited.
config TPL_SYS_MALLOC_F
bool "Enable malloc() pool in SPL"
bool "Enable malloc() pool in TPL"
depends on SYS_MALLOC_F && TPL
default y if SPL_SYS_MALLOC_F
help

View file

@ -93,16 +93,10 @@ u64 get_tcr(u64 *pips, u64 *pva_bits)
if (el == 1) {
tcr = TCR_EL1_RSVD | (ips << 32) | TCR_EPD1_DISABLE;
if (gd->arch.has_hafdbs)
tcr |= TCR_EL1_HA | TCR_EL1_HD;
} else if (el == 2) {
tcr = TCR_EL2_RSVD | (ips << 16);
if (gd->arch.has_hafdbs)
tcr |= TCR_EL2_HA | TCR_EL2_HD;
} else {
tcr = TCR_EL3_RSVD | (ips << 16);
if (gd->arch.has_hafdbs)
tcr |= TCR_EL3_HA | TCR_EL3_HD;
}
/* PTWs cacheable, inner/outer WBWA and inner shareable */
@ -206,9 +200,6 @@ static void __cmo_on_leaves(void (*cmo_fn)(unsigned long, unsigned long),
attrs != PTE_BLOCK_MEMTYPE(MT_NORMAL_NC))
continue;
if (gd->arch.has_hafdbs && (pte & (PTE_RDONLY | PTE_DBM)) != PTE_DBM)
continue;
end = va + BIT(level2shift(level)) - 1;
/* No intersection with RAM? */
@ -318,7 +309,7 @@ static void map_range(u64 virt, u64 phys, u64 size, int level,
for (i = idx; size; i++) {
u64 next_size, *next_table;
if (level >= gd->arch.first_block_level &&
if (level >= 1 &&
size >= map_size && !(virt & (map_size - 1))) {
if (level == 3)
table[i] = phys | attrs | PTE_TYPE_PAGE;
@ -357,12 +348,6 @@ static void add_map(struct mm_region *map)
if (va_bits < 39)
level = 1;
if (!gd->arch.first_block_level)
gd->arch.first_block_level = 1;
if (gd->arch.has_hafdbs)
attrs |= PTE_DBM | PTE_RDONLY;
map_range(map->virt, map->phys, map->size, level,
(u64 *)gd->arch.tlb_addr, attrs);
}
@ -376,7 +361,7 @@ static void count_range(u64 virt, u64 size, int level, int *cntp)
for (i = idx; size; i++) {
u64 next_size;
if (level >= gd->arch.first_block_level &&
if (level >= 1 &&
size >= map_size && !(virt & (map_size - 1))) {
virt += map_size;
size -= map_size;
@ -414,16 +399,7 @@ static int count_ranges(void)
__weak u64 get_page_table_size(void)
{
u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64);
u64 size, mmfr1;
asm volatile("mrs %0, id_aa64mmfr1_el1" : "=r" (mmfr1));
if ((mmfr1 & 0xf) == 2) {
gd->arch.has_hafdbs = true;
gd->arch.first_block_level = 2;
} else {
gd->arch.has_hafdbs = false;
gd->arch.first_block_level = 1;
}
u64 size;
/* Account for all page tables we would need to cover our memory map */
size = one_pt * count_ranges();

View file

@ -49,13 +49,10 @@
#define PTE_TYPE_BLOCK (1 << 0)
#define PTE_TYPE_VALID (1 << 0)
#define PTE_RDONLY BIT(7)
#define PTE_DBM BIT(51)
#define PTE_TABLE_PXN BIT(59)
#define PTE_TABLE_XN BIT(60)
#define PTE_TABLE_AP BIT(61)
#define PTE_TABLE_NS BIT(63)
#define PTE_TABLE_PXN (1UL << 59)
#define PTE_TABLE_XN (1UL << 60)
#define PTE_TABLE_AP (1UL << 61)
#define PTE_TABLE_NS (1UL << 63)
/*
* Block
@ -102,15 +99,6 @@
#define TCR_TG0_16K (2 << 14)
#define TCR_EPD1_DISABLE (1 << 23)
#define TCR_EL1_HA BIT(39)
#define TCR_EL1_HD BIT(40)
#define TCR_EL2_HA BIT(21)
#define TCR_EL2_HD BIT(22)
#define TCR_EL3_HA BIT(21)
#define TCR_EL3_HD BIT(22)
#define TCR_EL1_RSVD (1U << 31)
#define TCR_EL2_RSVD (1U << 31 | 1 << 23)
#define TCR_EL3_RSVD (1U << 31 | 1 << 23)

View file

@ -52,8 +52,6 @@ struct arch_global_data {
#if defined(CONFIG_ARM64)
unsigned long tlb_fillptr;
unsigned long tlb_emerg;
unsigned int first_block_level;
bool has_hafdbs;
#endif
#endif
#ifdef CFG_SYS_MEM_RESERVE_SECURE

View file

@ -162,7 +162,7 @@ static ulong spl_romapi_read_stream(struct spl_load_info *load, ulong sector,
return 0;
}
ss->end = end;
ss->end += bytes;
}
memcpy(buf, (void *)(sector), count);
@ -285,7 +285,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
ret = rom_api_download_image(p, 0, pg);
if (ret != ROM_API_OKAY) {
puts("Steam(USB) download failure\n");
puts("Stream(USB) download failure\n");
return -1;
}
@ -305,7 +305,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
ret = rom_api_download_image(p, 0, pg);
if (ret != ROM_API_OKAY) {
puts("Steam(USB) download failure\n");
puts("Stream(USB) download failure\n");
return -1;
}

View file

@ -467,7 +467,8 @@ void bootflow_free(struct bootflow *bflow)
free(bflow->name);
free(bflow->subdir);
free(bflow->fname);
free(bflow->buf);
if (!(bflow->flags & BOOTFLOWF_STATIC_BUF))
free(bflow->buf);
free(bflow->os_name);
free(bflow->fdt_fname);
free(bflow->bootmeth_priv);

View file

@ -160,6 +160,7 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr)
if (ret)
return log_msg_ret("read", ret);
bflow->buf = map_sysmem(addr, bflow->size);
bflow->flags |= BOOTFLOWF_STATIC_BUF;
set_efi_bootdev(desc, bflow);

View file

@ -20,7 +20,7 @@ struct virtio_rng_priv {
static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
{
int ret;
unsigned int rsize;
unsigned int rsize = 1;
unsigned char buf[BUFFER_SIZE] __aligned(4);
unsigned char *ptr = data;
struct virtio_sg sg;
@ -29,7 +29,12 @@ static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
while (len) {
sg.addr = buf;
sg.length = min(len, sizeof(buf));
/*
* Work around implementations which always return 8 bytes
* less than requested, down to 0 bytes, which would
* cause an endless loop otherwise.
*/
sg.length = min(rsize ? len : len + 8, sizeof(buf));
sgs[0] = &sg;
ret = virtqueue_add(priv->rng_vq, sgs, 0, 1);

View file

@ -43,9 +43,12 @@ enum bootflow_state_t {
* and it is using the prior-stage FDT, which is the U-Boot control FDT.
* This is only possible with the EFI bootmeth (distro-efi) and only when
* CONFIG_OF_HAS_PRIOR_STAGE is enabled
* @BOOTFLOWF_STATIC_BUF: Indicates that @bflow->buf is statically set, rather
* than being allocated by malloc().
*/
enum bootflow_flags_t {
BOOTFLOWF_USE_PRIOR_FDT = 1 << 0,
BOOTFLOWF_STATIC_BUF = 1 << 1,
};
/**
@ -72,7 +75,7 @@ enum bootflow_flags_t {
* @fname: Filename of bootflow file (allocated)
* @logo: Logo to display for this bootflow (BMP format)
* @logo_size: Size of the logo in bytes
* @buf: Bootflow file contents (allocated)
* @buf: Bootflow file contents (allocated unless @flags & BOOTFLOWF_STATIC_BUF)
* @size: Size of bootflow file in bytes
* @err: Error number received (0 if OK)
* @os_name: Name of the OS / distro being booted, or NULL if not known