Download raw body.
psp(4): Simplify wire/unwire for lauch update data
Hi,
when encrypting the pages used by a VM, instead of wiring page by page,
wire the whole range. And unwire it again, when we're done.
Take care,
HJ.
---------------------------------------------------------------------
commit f6a3dbd33066afa050f0022190466d3ae1496977
Author: Hans-Joerg Hoexer <hshoexer@genua.de>
Date: Wed Oct 30 19:25:42 2024 +0100
psp(4): Simplify wire/unwire for lauch update data
Instead of wiring page by page, wire the whole range.
diff --git a/sys/dev/ic/psp.c b/sys/dev/ic/psp.c
index 82b7f7f1abe..e697b307236 100644
--- a/sys/dev/ic/psp.c
+++ b/sys/dev/ic/psp.c
@@ -467,7 +467,7 @@ psp_launch_update_data(struct psp_softc *sc,
{
struct psp_launch_update_data *ludata;
pmap_t pmap;
- vaddr_t v, next, end;
+ vaddr_t v, next, start, end;
size_t size, len, off;
int ret;
@@ -492,31 +492,43 @@ psp_launch_update_data(struct psp_softc *sc,
* to system physical address.
*/
pmap = vm_map_pmap(&p->p_vmspace->vm_map);
+ start = ulud->paddr;
size = ulud->length;
- end = ulud->paddr + ulud->length;
+ end = start + size;
+
+ ret = EINVAL;
+
+ /* Wire mapping. */
+ if (uvm_map_pageable(&p->p_vmspace->vm_map, start, end, FALSE, 0))
+ goto out;
+
for (v = ulud->paddr; v < end; v = next) {
off = v & PAGE_MASK;
len = MIN(PAGE_SIZE - off, size);
- /* Wire mapping. */
- if (uvm_map_pageable(&p->p_vmspace->vm_map, v, v+len, FALSE, 0))
- return (EINVAL);
if (!pmap_extract(pmap, v, (paddr_t *)&ludata->paddr))
- return (EINVAL);
+ goto out;
ludata->length = len;
ret = ccp_docmd(sc, PSP_CMD_LAUNCH_UPDATE_DATA,
sc->sc_cmd_map->dm_segs[0].ds_addr);
- if (ret != 0)
- return (EIO);
+ if (ret != 0) {
+ ret = EIO;
+ goto out;
+ }
size -= len;
next = v + len;
}
- return (0);
+out:
+ /* Unwire again. */
+ if (uvm_map_pageable(&p->p_vmspace->vm_map, start, end, TRUE, 0))
+ return (EINVAL);
+
+ return (ret);
}
int
psp(4): Simplify wire/unwire for lauch update data