Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-08 Thread Borislav Petkov
On Thu, Apr 08, 2021 at 12:22:56PM +0300, Jarkko Sakkinen wrote: > They are not in the "free_page_list" before sanitization process has put > them to there. So in that way the count is also better in sync with this > fix. This is the bit of information I was looking for. This needs to be in the

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-08 Thread Jarkko Sakkinen
On Thu, Apr 08, 2021 at 10:56:40AM +0200, Borislav Petkov wrote: > On Thu, Apr 08, 2021 at 11:48:46AM +0300, Jarkko Sakkinen wrote: > > The regression is that the sgx_nr_free_pages is also incremented by > > sgx_free_epc_pages(), and thus it ends up having double the number of > > pages available.

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-08 Thread Borislav Petkov
On Thu, Apr 08, 2021 at 11:48:46AM +0300, Jarkko Sakkinen wrote: > The regression is that the sgx_nr_free_pages is also incremented by > sgx_free_epc_pages(), and thus it ends up having double the number of > pages available. So when you add a new EPC section with sgx_setup_epc_section(), those

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-08 Thread Jarkko Sakkinen
On Wed, Apr 07, 2021 at 06:18:11PM +0200, Borislav Petkov wrote: > On Wed, Apr 07, 2021 at 07:03:47PM +0300, Jarkko Sakkinen wrote: > > > Which leads to my question: what is sgx_nr_free_pages supposed to denote? > > > > > > Because I understand the callpath > > > > > > sgx_page_cache_init > > >

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-07 Thread Borislav Petkov
On Wed, Apr 07, 2021 at 07:03:47PM +0300, Jarkko Sakkinen wrote: > > Which leads to my question: what is sgx_nr_free_pages supposed to denote? > > > > Because I understand the callpath > > > > sgx_page_cache_init > > ... > > for (i = 0; i < ARRAY_SIZE(sgx_epc_sections); i++) { > > ... > >

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-07 Thread Jarkko Sakkinen
On Wed, Apr 07, 2021 at 05:49:34PM +0200, Borislav Petkov wrote: > On Tue, Apr 06, 2021 at 02:26:52AM +0300, Jarkko Sakkinen wrote: > > Now that the sanitization process will make pages available by calling > > sgx_free_epc_page(), sgx_setup_epc_section() should not touch to > > sgx_nr_free_pages.

Re: [PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-07 Thread Borislav Petkov
On Tue, Apr 06, 2021 at 02:26:52AM +0300, Jarkko Sakkinen wrote: > Now that the sanitization process will make pages available by calling > sgx_free_epc_page(), sgx_setup_epc_section() should not touch to > sgx_nr_free_pages. This will result sgx_nr_free_pages to contain 2x the > number of actual

[PATCH v2 1/2] x86/sgx: Do not update sgx_nr_free_pages in sgx_setup_epc_section()

2021-04-05 Thread Jarkko Sakkinen
Now that the sanitization process will make pages available by calling sgx_free_epc_page(), sgx_setup_epc_section() should not touch to sgx_nr_free_pages. This will result sgx_nr_free_pages to contain 2x the number of actual free pages. Simply, remove the statement. Fixes: 51ab30eb2ad4 ("x86/sgx: