[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMkAt6q=G96mG905u1GisbkVR42saPsgzQkXTtPVM=ar0Pdasg@mail.gmail.com>
Date: Mon, 10 May 2021 12:23:27 -0600
From: Peter Gonda <pgonda@...gle.com>
To: Brijesh Singh <brijesh.singh@....com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
kvm list <kvm@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>, jroedel@...e.de,
"Lendacky, Thomas" <thomas.lendacky@....com>,
Paolo Bonzini <pbonzini@...hat.com>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...el.com>,
David Rientjes <rientjes@...gle.com>,
Sean Christopherson <seanjc@...gle.com>, peterz@...radead.org,
"H. Peter Anvin" <hpa@...or.com>, tony.luck@...el.com
Subject: Re: [PATCH Part2 RFC v2 16/37] crypto: ccp: Handle the legacy TMR
allocation when SNP is enabled
> +
> +static int snp_set_rmptable_state(unsigned long paddr, int npages,
> + struct rmpupdate *val, bool locked, bool need_reclaim)
> +{
> + unsigned long pfn = __sme_clr(paddr) >> PAGE_SHIFT;
> + unsigned long pfn_end = pfn + npages;
> + int rc;
> +
> + while (pfn < pfn_end) {
> + if (need_reclaim)
> + if (snp_reclaim_page(pfn_to_page(pfn), locked))
> + return -EFAULT;
> +
> + rc = rmpupdate(pfn_to_page(pfn), val);
> + if (rc)
> + return rc;
This functional can return an error but have partially converted some
of the npages requested by the caller. Should this function return the
number of affected pages or something to allow the caller to know if
some pages need to be reverted? Or should the function attempt to do
that itself?
> +
> + pfn++;
> + }
> +
> + return 0;
> +}
> +
> +static void __snp_free_firmware_pages(struct page *page, int order)
> +{
> + struct rmpupdate val = {};
> + unsigned long paddr;
> +
> + if (!page)
> + return;
> +
> + paddr = __pa((unsigned long)page_address(page));
> +
> + if (snp_set_rmptable_state(paddr, 1 << order, &val, false, true))
> + return;
We now have leaked the given pages right? Should some warning be
logged or should we track these leaked pages and maybe try and free
them with a kworker?
> +
> + __free_pages(page, order);
> +}
> +
Powered by blists - more mailing lists