On Fri, Jul 16, 2021, Brijesh Singh wrote: > > On 7/15/21 6:48 PM, Sean Christopherson wrote: > > On Wed, Jul 07, 2021, Brijesh Singh wrote: > >> @@ -1204,16 +1322,6 @@ void sev_pci_init(void) > >> sev_update_firmware(sev->dev) == 0) > >> sev_get_api_version(); > >> > >> - /* Obtain the TMR memory area for SEV-ES use */ > >> - tmr_page = alloc_pages(GFP_KERNEL, get_order(SEV_ES_TMR_SIZE)); > >> - if (tmr_page) { > >> - sev_es_tmr = page_address(tmr_page); > >> - } else { > >> - sev_es_tmr = NULL; > >> - dev_warn(sev->dev, > >> - "SEV: TMR allocation failed, SEV-ES support unavailable\n"); > >> - } > >> - > >> /* > >> * If boot CPU supports the SNP, then first attempt to initialize > >> * the SNP firmware. > >> @@ -1229,6 +1337,16 @@ void sev_pci_init(void) > >> } > >> } > >> > >> + /* Obtain the TMR memory area for SEV-ES use */ > >> + tmr_page = __snp_alloc_firmware_pages(GFP_KERNEL, get_order(sev_es_tmr_size), false); > >> + if (tmr_page) { > >> + sev_es_tmr = page_address(tmr_page); > >> + } else { > >> + sev_es_tmr = NULL; > >> + dev_warn(sev->dev, > >> + "SEV: TMR allocation failed, SEV-ES support unavailable\n"); > >> + } > > I think your patch ordering got a bit wonky. AFAICT, the chunk that added > > sev_snp_init() and friends in the previous patch 14 should have landed above > > the TMR allocation, i.e. the code movement here should be unnecessary. > > I was debating about it whether to include all the SNP supports in one > patch or divide it up. If I had included all legacy support new > requirement in the same patch which adds the SNP then it will be a big > patch. I had feeling that others may ask me to split it. It wasn't comment on the patch organization, rather that the code added in patch 14 appears to have landed in the wrong location within the code. The above diff shows that the TMR allocation is being moved around the SNP initialization code that was added in patch 14 (the immediately prior patch). Presumably the required order doesn't magically change just because the TMR is now being allocated as a 2mb blob, so either the code movement is unnecessary churn or the original location was wrong. In either case, landing the SNP initialization code above the TMR allocation in patch 14 would eliminate the above code movement.