mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-11 20:05:22 +02:00
s390/mm: Convert make_page_secure to use a folio
[ Upstream commit259e660d91
] These page APIs are deprecated, so convert the incoming page to a folio and use the folio APIs instead. The ultravisor API cannot handle large folios, so return -EINVAL if one has slipped through. Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://lore.kernel.org/r/20240322161149.2327518-2-willy@infradead.org Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Stable-dep-of:3f29f6537f
("s390/uv: Don't call folio_wait_writeback() without a folio reference") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
249212ceb4
commit
098ca9219c
|
@ -181,21 +181,21 @@ int uv_convert_owned_from_secure(unsigned long paddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the expected ref_count for a page that would otherwise have no
|
* Calculate the expected ref_count for a folio that would otherwise have no
|
||||||
* further pins. This was cribbed from similar functions in other places in
|
* further pins. This was cribbed from similar functions in other places in
|
||||||
* the kernel, but with some slight modifications. We know that a secure
|
* the kernel, but with some slight modifications. We know that a secure
|
||||||
* page can not be a huge page for example.
|
* folio can not be a large folio, for example.
|
||||||
*/
|
*/
|
||||||
static int expected_page_refs(struct page *page)
|
static int expected_folio_refs(struct folio *folio)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = page_mapcount(page);
|
res = folio_mapcount(folio);
|
||||||
if (PageSwapCache(page)) {
|
if (folio_test_swapcache(folio)) {
|
||||||
res++;
|
res++;
|
||||||
} else if (page_mapping(page)) {
|
} else if (folio_mapping(folio)) {
|
||||||
res++;
|
res++;
|
||||||
if (page_has_private(page))
|
if (folio->private)
|
||||||
res++;
|
res++;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -203,14 +203,17 @@ static int expected_page_refs(struct page *page)
|
||||||
|
|
||||||
static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
|
static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
|
||||||
{
|
{
|
||||||
|
struct folio *folio = page_folio(page);
|
||||||
int expected, cc = 0;
|
int expected, cc = 0;
|
||||||
|
|
||||||
if (PageWriteback(page))
|
if (folio_test_large(folio))
|
||||||
|
return -EINVAL;
|
||||||
|
if (folio_test_writeback(folio))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
expected = expected_page_refs(page);
|
expected = expected_folio_refs(folio);
|
||||||
if (!page_ref_freeze(page, expected))
|
if (!folio_ref_freeze(folio, expected))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
set_bit(PG_arch_1, &page->flags);
|
set_bit(PG_arch_1, &folio->flags);
|
||||||
/*
|
/*
|
||||||
* If the UVC does not succeed or fail immediately, we don't want to
|
* If the UVC does not succeed or fail immediately, we don't want to
|
||||||
* loop for long, or we might get stall notifications.
|
* loop for long, or we might get stall notifications.
|
||||||
|
@ -220,9 +223,9 @@ static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
|
||||||
* -EAGAIN and we let the callers deal with it.
|
* -EAGAIN and we let the callers deal with it.
|
||||||
*/
|
*/
|
||||||
cc = __uv_call(0, (u64)uvcb);
|
cc = __uv_call(0, (u64)uvcb);
|
||||||
page_ref_unfreeze(page, expected);
|
folio_ref_unfreeze(folio, expected);
|
||||||
/*
|
/*
|
||||||
* Return -ENXIO if the page was not mapped, -EINVAL for other errors.
|
* Return -ENXIO if the folio was not mapped, -EINVAL for other errors.
|
||||||
* If busy or partially completed, return -EAGAIN.
|
* If busy or partially completed, return -EAGAIN.
|
||||||
*/
|
*/
|
||||||
if (cc == UVC_CC_OK)
|
if (cc == UVC_CC_OK)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user