On Thu, Jan 25, 2024 at 10:11:16PM -0600, Michael Roth wrote: > @@ -641,14 +774,16 @@ static int __sev_platform_init_locked(int *error) That function - especially when looking at the next patch - becomes too big and hard to follow. Let's add subfunctions for each thing, diff ontop: --- diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index fa992ce57ffe..70aabd1d3d5f 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -759,6 +759,22 @@ static int __sev_snp_init_locked(int *error) return rc; } +static void __sev_platform_init_handle_tmr(struct sev_device *sev) +{ + if (sev_es_tmr) + return; + + /* Obtain the TMR memory area for SEV-ES use */ + sev_es_tmr = sev_fw_alloc(sev_es_tmr_size); + if (sev_es_tmr) { + /* Must flush the cache before giving it to the firmware */ + if (!sev->snp_initialized) + clflush_cache_range(sev_es_tmr, sev_es_tmr_size); + } else { + dev_warn(sev->dev, "SEV: TMR allocation failed, SEV-ES support unavailable\n"); + } +} + static int __sev_platform_init_locked(int *error) { int rc, psp_ret = SEV_RET_NO_FW_CALL; @@ -772,18 +788,7 @@ static int __sev_platform_init_locked(int *error) if (sev->state == SEV_STATE_INIT) return 0; - if (!sev_es_tmr) { - /* Obtain the TMR memory area for SEV-ES use */ - sev_es_tmr = sev_fw_alloc(sev_es_tmr_size); - if (sev_es_tmr) { - /* Must flush the cache before giving it to the firmware */ - if (!sev->snp_initialized) - clflush_cache_range(sev_es_tmr, sev_es_tmr_size); - } else { - dev_warn(sev->dev, - "SEV: TMR allocation failed, SEV-ES support unavailable\n"); - } - } + __sev_platform_init_handle_tmr(sev); if (sev_init_ex_buffer) { rc = sev_read_init_ex_file(); -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette