Giter VIP home page Giter VIP logo

xnu-bcm2837-hackintosh's Issues

[IOKit] vm_pageout_wait undefined

Temporarily remove

#if defined(XNU_TARGET_OS_OSX)
			// vm_pageout_wait(AbsoluteTime_to_scalar(&deadline));
#endif /* defined(XNU_TARGET_OS_OSX) */

[OSFMK] member named 'disable_jop' not presented in 'struct pmap'

Error message:

/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_shared_region.c:1067:24: error: no member named 'disable_jop' in 'struct pmap'
            !task->map->pmap->disable_jop) {
             ~~~~~~~~~~~~~~~  ^

The pmap struct is defined as follows:

struct pmap {
	tt_entry_t              *XNU_PTRAUTH_SIGNED_PTR("pmap.tte") tte; /* translation table entries */
	pmap_paddr_t            ttep;                   /* translation table physical */
	vm_map_address_t        min;                    /* min address in pmap */
	vm_map_address_t        max;                    /* max address in pmap */
#if ARM_PARAMETERIZED_PMAP
	const struct page_table_attr * pmap_pt_attr;    /* details about page table layout */
#endif /* ARM_PARAMETERIZED_PMAP */
	ledger_t                ledger;                 /* ledger tracking phys mappings */

	decl_lck_rw_data(, rwlock);

	struct pmap_statistics  stats;          /* map statistics */
	queue_chain_t           pmaps;                  /* global list of pmaps */
	tt_entry_t                      *tt_entry_free; /* free translation table entries */
	struct pmap                     *XNU_PTRAUTH_SIGNED_PTR("pmap.nested_pmap") nested_pmap;   /* nested pmap */
	vm_map_address_t        nested_region_addr;
	vm_map_offset_t         nested_region_size;
	vm_map_offset_t         nested_region_true_start;
	vm_map_offset_t         nested_region_true_end;
	unsigned int            *nested_region_asid_bitmap;

#if (__ARM_VMSA__ <= 7)
	unsigned int            tte_index_max;          /* max tte index in translation table entries */
#endif

	void *                  reserved0;
	void *                  reserved1;
	uint64_t                reserved2;
	uint64_t                reserved3;

	unsigned int            stamp;                  /* creation stamp */
	_Atomic int32_t         ref_count;              /* pmap reference count */
	unsigned int            gc_status;              /* gc status */
	unsigned int            nested_region_asid_bitmap_size;
	uint32_t                nested_no_bounds_refcnt;/* number of pmaps that nested this pmap without bounds set */
	uint16_t                hw_asid;
	uint8_t                 sw_asid;

#if MACH_ASSERT
	int                     pmap_pid;
	char                    pmap_procname[17];
	bool            pmap_stats_assert;
#endif /* MACH_ASSERT */
	bool                    reserved4;
	bool                    pmap_vm_map_cs_enforced;
	boolean_t               reserved5;
	uint64_t                reserved6;
	uint64_t                reserved7;
	bool                    reserved8;
	bool                    reserved9;
#if DEVELOPMENT || DEBUG
	bool            footprint_suspended;
	bool            footprint_was_suspended;
#endif /* DEVELOPMENT || DEBUG */
	bool            nx_enabled;                             /* no execute */
	bool            nested;                                 /* is nested */
	bool            is_64bit;                               /* is 64bit */
	bool            nested_has_no_bounds_ref;       /* nested a pmap when the bounds were not set */
	bool            nested_bounds_set;                      /* The nesting bounds have been set */
#if HAS_APPLE_PAC
	bool            disable_jop;
#else
	bool            reserved10;
#endif /* HAS_APPLE_PAC */
};

The HAS_APPLE_PAC flag prevents us from having that field. It is defined in some platform-expert files.

[Makefile] EMBEDDED_DEVICE_MAP is empty

Error message:

make[4]: -db: Command not found

Defined:

# Platform-specific tools
ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
ifeq ($(EMBEDDED_DEVICE_MAP),)
	export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map)
endif
EDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
endif

which exists only in iPhone SDK

[OSFMK] no member named 'jop_pid' in 'struct task'

Error message:

/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_shared_region.c:1135:28: error: no member named 'jop_pid' in 'struct task'
                    use_ptr_auth ? task->jop_pid : 0);
                                   ~~~~  ^

The struct task has a macro MACHINE_TASK. This MACRO has PAC related flatting on ARM arch.

#if defined(HAS_APPLE_PAC)
#define TASK_ADDITIONS_PAC \
	uint64_t rop_pid; \
	uint64_t jop_pid; \
	uint8_t disable_user_jop;
#else
#define TASK_ADDITIONS_PAC
#endif

#define MACHINE_TASK \
	void* task_debug; \
	TASK_ADDITIONS_PAC \

Uncategorized

/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_shared_region.c:2835:24: error: implicit declaration of function 'pmap_sign_user_ptr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                value = (uintptr_t)pmap_sign_user_ptr((void *)value, key, discriminator, jop_key);
                                                   ^
/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_shared_region_pager.c:227:23: error: implicit declaration of function 'ml_default_jop_pid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                        new->srk_jop_key = ml_default_jop_pid();
                                           ^

[OSFMK] No member vmmap_high_start in 'struct _vm_map'

The output is as follows:

/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_map.c:1298:10: error: no member named 'vmmap_high_start' in 'struct _vm_map'
        result->vmmap_high_start = 0;
        ~~~~~~  ^
/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_map.c:2707:12: error: no member named 'vmmap_high_start' in 'struct _vm_map'
                    map->vmmap_high_start != 0) {
                    ~~~  ^
/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_map.c:2708:17: error: no member named 'vmmap_high_start' in 'struct _vm_map'
                        start = map->vmmap_high_start;
                                ~~~  ^
/Users/inoki/Build/bigsur-arm64/xnu-7195.81.3/osfmk/vm/vm_map.c:20996:7: error: no member named 'vmmap_high_start' in 'struct _vm_map'
        map->vmmap_high_start = high_start;

For BCM2837 target, there is:

#  KERNEL_BASE =    [ arm64 xsmall msgb_small config_embedded config_requires_u32_munging config_zcache ARM_EXTRAS_BASE ]

which incurs vm_map_offset_t vmmap_high_start; not defined in struct _vm_map:

struct _vm_map {
	lck_rw_t                lock;           /* map lock */
	struct vm_map_header    hdr;            /* Map entry header */
#define min_offset              hdr.links.start /* start of range */
#define max_offset              hdr.links.end   /* end of range */
	pmap_t                  XNU_PTRAUTH_SIGNED_PTR("_vm_map.pmap") pmap;           /* Physical map */
	vm_map_size_t           size;           /* virtual size */
	vm_map_size_t           user_wire_limit;/* rlimit on user locked memory */
	vm_map_size_t           user_wire_size; /* current size of user locked memory in this map */
#if !CONFIG_EMBEDDED
	vm_map_offset_t         vmmap_high_start;
#endif

Bootloader work

Hey! I stumbled across your repo and managed to build XNU successfully however I have issues booting it. I have a little bit of experience with ARM64 and managed to patch limine to load and run the kernel. However it crashes at arm_init basically after setting up the page tables and jumping into C code. You seemed like the guy who might know what went wrong so opening the issue here. Really sorry if I disturbed you or approached the wrong person and REALLY sorry I am opening this issue this late.

You can find the patches I made here

Thank you in advance!

[Build] ARM64 setup

In makedefs/MakeInc.def, change these:

ifneq ($(filter ARM ARM64,$(CURRENT_ARCH_CONFIG)),)

ifneq ($(findstring _Sim,$(RC_ProjectName)),)
ARCH_FLAGS_ARM64          = -arch arm64
else ifneq ($(findstring _host,$(RC_ProjectName)),)
ARCH_FLAGS_ARM64          = -arch arm64
else

ifndef ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG

ifneq ($(EMBEDDED_DEVICE_MAP),)
export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT KernelMachOArchitecture FROM Targets WHERE KernelPlatform IS \"$(CURRENT_MACHINE_CONFIG_LC)\" LIMIT 1 || echo UNKNOWN )
else
# Without embdedded device map, use a default arch string
export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := $(shell echo $(CURRENT_ARCH_CONFIG) | tr A-Z a-z)
ifneq ($(filter ARM64,$(CURRENT_ARCH_CONFIG)),)
export ARCH_STRING_FOR_CURRENT_MACHINE_CONFIG := arm64
endif
endif
endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.