Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/portal/portal_anon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/net.h>
#include <linux/file.h>
#include "portal_devfs.h"
#include "portal_mmap.h"


struct portal_anonfs_create_req {
Expand Down Expand Up @@ -44,7 +45,7 @@ static int igloo_anonfs_proxy_mmap(struct file *file, struct vm_area_struct *vma
size_t size = vma->vm_end - vma->vm_start;

if (pe && pe->mmap_phys_addr) {
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_page_prot = igloo_mmap_phys_pgprot(vma->vm_page_prot);
return remap_pfn_range(vma, vma->vm_start, pe->mmap_phys_addr >> PAGE_SHIFT,
size, vma->vm_page_prot);
}
Expand Down Expand Up @@ -205,4 +206,4 @@ void handle_op_sockfs_create_socket(portal_region *mem_region) {

fail:
mem_region->header.op = HYPER_RESP_WRITE_FAIL;
}
}
3 changes: 2 additions & 1 deletion src/portal/portal_devfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/blk-mq.h>

#include "portal_devfs.h"
#include "portal_mmap.h"

// Request to create a directory in devfs
struct portal_devfs_dir_req {
Expand Down Expand Up @@ -225,7 +226,7 @@ static int igloo_devfs_proxy_mmap(struct file *file, struct vm_area_struct *vma)

if (pe->mmap_phys_addr) {
// NATIVE QEMU MMAP: Directly map the physical address assigned by Penguin
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_page_prot = igloo_mmap_phys_pgprot(vma->vm_page_prot);
return remap_pfn_range(vma, vma->vm_start, pe->mmap_phys_addr >> PAGE_SHIFT,
size, vma->vm_page_prot);
}
Expand Down
20 changes: 20 additions & 0 deletions src/portal/portal_mmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef IGLOO_PORTAL_MMAP_H
#define IGLOO_PORTAL_MMAP_H

#include <linux/mm.h>

static inline pgprot_t igloo_mmap_phys_pgprot(pgprot_t prot)
{
#if defined(CONFIG_ARM64)
/*
* arm64 maps pgprot_noncached() as device memory. User-space string and
* runtime helpers may issue unaligned accesses into mmap()ed pseudo-files,
* and device mappings fault on those accesses before QEMU sees the MMIO.
*/
return pgprot_writecombine(prot);
#else
return pgprot_noncached(prot);
#endif
}

#endif
3 changes: 2 additions & 1 deletion src/portal/portal_procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "../args.h"
#include "portal_procfs.h"
#include "portal_mmap.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,13,0)
#define IGLOO_NEEDS_PROC_PERMANENT_CLEAR 1
Expand Down Expand Up @@ -103,7 +104,7 @@ int igloo_proxy_mmap(struct file *file, struct vm_area_struct *vma)

if (pe->mmap_phys_addr) {
// NATIVE QEMU MMAP: Directly map the physical address assigned by Penguin
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_page_prot = igloo_mmap_phys_pgprot(vma->vm_page_prot);
return remap_pfn_range(vma, vma->vm_start, pe->mmap_phys_addr >> PAGE_SHIFT,
size, vma->vm_page_prot);
}
Expand Down
Loading