File tree Expand file tree Collapse file tree 1 file changed +10
-26
lines changed Expand file tree Collapse file tree 1 file changed +10
-26
lines changed Original file line number Diff line number Diff line change @@ -1324,45 +1324,29 @@ void hyp_unpin_shared_mem(void *from, void *to)
1324
1324
1325
1325
int __pkvm_host_share_ffa (u64 pfn , u64 nr_pages )
1326
1326
{
1327
+ u64 phys = hyp_pfn_to_phys (pfn );
1328
+ u64 size = PAGE_SIZE * nr_pages ;
1327
1329
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
- };
1340
1330
1341
1331
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 );
1343
1335
host_unlock_component ();
1344
1336
1345
1337
return ret ;
1346
1338
}
1347
1339
1348
1340
int __pkvm_host_unshare_ffa (u64 pfn , u64 nr_pages )
1349
1341
{
1342
+ u64 phys = hyp_pfn_to_phys (pfn );
1343
+ u64 size = PAGE_SIZE * nr_pages ;
1350
1344
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
- };
1363
1345
1364
1346
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 );
1366
1350
host_unlock_component ();
1367
1351
1368
1352
return ret ;
You can’t perform that action at this time.
0 commit comments