Skip to content

Commit 259e660

Browse files
Matthew Wilcox (Oracle)Alexander Gordeev
authored andcommitted
s390/mm: Convert make_page_secure to use a folio
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>
1 parent f10933c commit 259e660

File tree

1 file changed

+16
-13
lines changed
  • arch/s390/kernel

1 file changed

+16
-13
lines changed

arch/s390/kernel/uv.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,39 @@ int uv_convert_owned_from_secure(unsigned long paddr)
182182
}
183183

184184
/*
185-
* Calculate the expected ref_count for a page that would otherwise have no
185+
* Calculate the expected ref_count for a folio that would otherwise have no
186186
* further pins. This was cribbed from similar functions in other places in
187187
* the kernel, but with some slight modifications. We know that a secure
188-
* page can not be a huge page for example.
188+
* folio can not be a large folio, for example.
189189
*/
190-
static int expected_page_refs(struct page *page)
190+
static int expected_folio_refs(struct folio *folio)
191191
{
192192
int res;
193193

194-
res = page_mapcount(page);
195-
if (PageSwapCache(page)) {
194+
res = folio_mapcount(folio);
195+
if (folio_test_swapcache(folio)) {
196196
res++;
197-
} else if (page_mapping(page)) {
197+
} else if (folio_mapping(folio)) {
198198
res++;
199-
if (page_has_private(page))
199+
if (folio->private)
200200
res++;
201201
}
202202
return res;
203203
}
204204

205205
static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
206206
{
207+
struct folio *folio = page_folio(page);
207208
int expected, cc = 0;
208209

209-
if (PageWriteback(page))
210+
if (folio_test_large(folio))
211+
return -EINVAL;
212+
if (folio_test_writeback(folio))
210213
return -EAGAIN;
211-
expected = expected_page_refs(page);
212-
if (!page_ref_freeze(page, expected))
214+
expected = expected_folio_refs(folio);
215+
if (!folio_ref_freeze(folio, expected))
213216
return -EBUSY;
214-
set_bit(PG_arch_1, &page->flags);
217+
set_bit(PG_arch_1, &folio->flags);
215218
/*
216219
* If the UVC does not succeed or fail immediately, we don't want to
217220
* loop for long, or we might get stall notifications.
@@ -221,9 +224,9 @@ static int make_page_secure(struct page *page, struct uv_cb_header *uvcb)
221224
* -EAGAIN and we let the callers deal with it.
222225
*/
223226
cc = __uv_call(0, (u64)uvcb);
224-
page_ref_unfreeze(page, expected);
227+
folio_ref_unfreeze(folio, expected);
225228
/*
226-
* Return -ENXIO if the page was not mapped, -EINVAL for other errors.
229+
* Return -ENXIO if the folio was not mapped, -EINVAL for other errors.
227230
* If busy or partially completed, return -EAGAIN.
228231
*/
229232
if (cc == UVC_CC_OK)

0 commit comments

Comments
 (0)