Skip to content

Commit 7a06888

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Drop pkvm_mem_transition for FF-A
Simplify the __pkvm_host_{un}share_ffa() paths by using {check,set}_page_state_range(). No functional changes intended. Signed-off-by: Quentin Perret <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 60f20d8 commit 7a06888

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

arch/arm64/kvm/hyp/nvhe/mem_protect.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,45 +1324,29 @@ void hyp_unpin_shared_mem(void *from, void *to)
13241324

13251325
int __pkvm_host_share_ffa(u64 pfn, u64 nr_pages)
13261326
{
1327+
u64 phys = hyp_pfn_to_phys(pfn);
1328+
u64 size = PAGE_SIZE * nr_pages;
13271329
int ret;
1328-
struct pkvm_mem_share share = {
1329-
.tx = {
1330-
.nr_pages = nr_pages,
1331-
.initiator = {
1332-
.id = PKVM_ID_HOST,
1333-
.addr = hyp_pfn_to_phys(pfn),
1334-
},
1335-
.completer = {
1336-
.id = PKVM_ID_FFA,
1337-
},
1338-
},
1339-
};
13401330

13411331
host_lock_component();
1342-
ret = do_share(&share);
1332+
ret = __host_check_page_state_range(phys, size, PKVM_PAGE_OWNED);
1333+
if (!ret)
1334+
ret = __host_set_page_state_range(phys, size, PKVM_PAGE_SHARED_OWNED);
13431335
host_unlock_component();
13441336

13451337
return ret;
13461338
}
13471339

13481340
int __pkvm_host_unshare_ffa(u64 pfn, u64 nr_pages)
13491341
{
1342+
u64 phys = hyp_pfn_to_phys(pfn);
1343+
u64 size = PAGE_SIZE * nr_pages;
13501344
int ret;
1351-
struct pkvm_mem_share share = {
1352-
.tx = {
1353-
.nr_pages = nr_pages,
1354-
.initiator = {
1355-
.id = PKVM_ID_HOST,
1356-
.addr = hyp_pfn_to_phys(pfn),
1357-
},
1358-
.completer = {
1359-
.id = PKVM_ID_FFA,
1360-
},
1361-
},
1362-
};
13631345

13641346
host_lock_component();
1365-
ret = do_unshare(&share);
1347+
ret = __host_check_page_state_range(phys, size, PKVM_PAGE_SHARED_OWNED);
1348+
if (!ret)
1349+
ret = __host_set_page_state_range(phys, size, PKVM_PAGE_OWNED);
13661350
host_unlock_component();
13671351

13681352
return ret;

0 commit comments

Comments
 (0)