mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
arm64: fix PAC/BTI ABI flags, host WC flush, NEON/FP checker, ARM64 strip-unneeded, and LP64 guards
Gate objcopy --strip-unneeded to ARM64 only so x86_64 preserves local STT_FUNC symbols required by CONFIG_CALL_PADDING/IBT validation in check_kernel_module.py.
This commit is contained in:
@ -16,7 +16,16 @@ typedef uint64_t nv_rs_u64;
|
||||
#define NV_RS_XFER_CMD 211U
|
||||
struct nv_rs_xfer { nv_rs_u32 command; nv_rs_u32 size; nv_rs_u64 pointer; };
|
||||
struct nv_rs_request { nv_rs_u32 command; nv_rs_u32 size; nv_rs_u64 pointer; };
|
||||
/* Native x86_64 only. A single XFER envelope; no recursive transport nesting. */
|
||||
/* LP64 wire/ioctl policy (x86_64 and AArch64 share asm-generic/ioctl.h bitfields
|
||||
* and identical natural alignment for u32/u64). A single XFER envelope; no recursive transport nesting. */
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
_Static_assert(sizeof(struct nv_rs_xfer) == 16, "nv_rs_xfer must be 16 bytes (LP64 ABI)");
|
||||
_Static_assert(sizeof(struct nv_rs_request) == 16, "nv_rs_request must be 16 bytes (LP64 ABI)");
|
||||
_Static_assert(__builtin_offsetof(struct nv_rs_xfer, size) == 4, "nv_rs_xfer.size offset");
|
||||
_Static_assert(__builtin_offsetof(struct nv_rs_xfer, pointer) == 8, "nv_rs_xfer.pointer offset");
|
||||
_Static_assert(__builtin_offsetof(struct nv_rs_request, size) == 4, "nv_rs_request.size offset");
|
||||
_Static_assert(__builtin_offsetof(struct nv_rs_request, pointer) == 8, "nv_rs_request.pointer offset");
|
||||
#endif
|
||||
static inline int nv_rs_plan(unsigned int ioctl_command, nv_rs_u64 user_pointer,
|
||||
const struct nv_rs_xfer *xfer,
|
||||
struct nv_rs_request *request)
|
||||
|
||||
@ -603,12 +603,14 @@ void nv_rs_pci_fifo_irq_unlock(struct nv_rs_pci *p, unsigned long flags)
|
||||
|
||||
void nv_rs_pci_context_wc_flush(void)
|
||||
{
|
||||
#if defined(CONFIG_X86_64) || defined(NV_RS_PCI_HOST_FIXTURE)
|
||||
#if defined(CONFIG_X86_64) || (defined(NV_RS_PCI_HOST_FIXTURE) && defined(__x86_64__))
|
||||
__asm__ __volatile__("sfence" ::: "memory");
|
||||
#elif defined(CONFIG_ARM64)
|
||||
#elif defined(CONFIG_ARM64) || (defined(NV_RS_PCI_HOST_FIXTURE) && defined(__aarch64__))
|
||||
__asm__ __volatile__("dsb st" ::: "memory");
|
||||
#elif defined(NV_RS_PCI_HOST_FIXTURE)
|
||||
__sync_synchronize();
|
||||
#else
|
||||
mb();
|
||||
wmb();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
ROOT := $(abspath ../..)
|
||||
include $(ROOT)/utils.mk
|
||||
NM ?= nm
|
||||
RUST_COMMON := $(filter-out --crate-type=lib --emit=obj,$(RUST_KERNEL_FLAGS)) -C embed-bitcode=yes
|
||||
RUST_COMMON := $(filter-out --crate-type=lib --emit=obj,$(RUST_KERNEL_FLAGS)) -C embed-bitcode=yes $(RUST_KERNEL_EXTRA_FLAGS)
|
||||
OUT := $(ROOT)/kernel-open/nvidia
|
||||
ABI_SRC := $(ROOT)/src/common/abi/src/lib.rs
|
||||
CORE_SRC := $(shell find src -name '*.rs')
|
||||
@ -18,9 +18,12 @@ $(OUT)/libnv_rs_kernel.a: kernel/lib.rs $(KERNEL_SRC) $(OUT)/libnv_rs_core.rlib
|
||||
# compiled with this kernel's return-thunk/IBT flags. Linux exports strlen.
|
||||
$(OUT)/libnv_rs_kernel.kernel.a: $(OUT)/libnv_rs_kernel.a $(ROOT)/tools/prepare_kernel_archive.py Makefile
|
||||
python3 $(ROOT)/tools/prepare_kernel_archive.py $< $@ --ar "$(AR)" --nm "$(NM)"
|
||||
# Keep local STT_FUNC symbols on x86_64 for CONFIG_CALL_PADDING/IBT checks;
|
||||
# on ARM64, --strip-unneeded drops unreachable local symbols before modpost.
|
||||
OBJCOPY_STRIP_FLAGS := $(if $(filter arm64 aarch64,$(NV_RS_ARCH)),--strip-unneeded,)
|
||||
$(OUT)/nv-rust.o_binary: $(OUT)/libnv_rs_kernel.kernel.a
|
||||
$(LD) -r --gc-sections --whole-archive $< --no-whole-archive $(foreach name,protocol_version rmapi_state_size rmapi_state_align rmapi_init rmapi_gpu_add rmapi_gpu_remove rmapi_gpu_minor rmapi_gpu_open rmapi_attach_register_count rmapi_attach_register rmapi_gpu_needs_registers rmapi_gpu_attach_registers rmapi_set_host_bridge rmapi_set_force_p2p rmapi_set_gsp_abi rmapi_set_driver_version rmapi_gpu_release rmapi_register_fd rmapi_prepare rmapi_nested_plan rmapi_execute rmapi_copy_fault rmapi_close rmapi_rc_recover_fault alloc_reg_can_admit alloc_reg_insert alloc_reg_find alloc_reg_retain alloc_reg_mark_freed_and_put alloc_reg_put_ptr alloc_reg_for_each alloc_reg_total_pages alloc_reg_pop_any alloc_reg_release_storage dma_reg_find dma_reg_insert dma_reg_pop_for_alloc dma_reg_pop_for_dev file_map_insert_alloc file_map_insert_io file_map_get file_map_remove gpu_slot_activate gpu_slot_deactivate gpu_slot_is_live_gen gpu_slot_set_numa gpu_slot_validate_bar0 gpu_slot_validate_bar1 uvm_file_size uvm_file_align uvm_file_init uvm_route_size uvm_route_status_offset uvm_file_ioctl uvm_file_mmap uvm_file_vma_closed uvm_file_release uvm_service_replayable_faults uvm_node_cleanup uvm_iface_register_uvm_callbacks uvm_iface_deregister_uvm_ops uvm_iface_register_gpu uvm_iface_unregister_gpu uvm_iface_session_create uvm_iface_session_destroy uvm_iface_device_create uvm_iface_device_destroy uvm_iface_get_gpu_info uvm_iface_get_fb_info uvm_iface_get_ecc_info uvm_iface_get_nvlink_info uvm_iface_query_caps uvm_iface_query_copy_engines_caps uvm_iface_memory_alloc_fb uvm_iface_memory_alloc_sys uvm_iface_memory_free uvm_iface_service_device_interrupts_rm uvm_iface_own_page_fault_intr uvm_iface_address_space_create uvm_iface_address_space_destroy uvm_iface_set_page_directory uvm_iface_unset_page_directory uvm_iface_p2p_object_create uvm_iface_p2p_object_destroy uvm_iface_tsg_allocate uvm_iface_tsg_destroy uvm_iface_channel_allocate uvm_iface_channel_destroy uvm_iface_paging_channel_allocate uvm_iface_paging_channel_destroy uvm_iface_toggle_prefetch_faults uvm_iface_report_fatal_error uvm_iface_init_access_cntr_info uvm_iface_destroy_access_cntr_info uvm_iface_enable_access_cntr uvm_iface_disable_access_cntr uvm_iface_flush_replayable_fault_buffer uvm_iface_has_pending_non_replayable_faults uvm_iface_dup_address_space uvm_iface_dup_allocation uvm_iface_dup_memory uvm_iface_free_duped_handle uvm_iface_memory_cpu_map uvm_iface_memory_cpu_unmap uvm_iface_retain_channel uvm_iface_bind_channel_resources uvm_iface_stop_channel uvm_iface_release_channel uvm_iface_paging_channels_map uvm_iface_paging_channels_unmap uvm_iface_paging_channel_push_stream uvm_iface_report_non_replayable_fault uvm_iface_get_non_replayable_faults uvm_iface_get_pma_object uvm_iface_pma_register_eviction_callbacks uvm_iface_pma_unregister_eviction_callbacks uvm_iface_init_fault_info uvm_iface_destroy_fault_info uvm_iface_get_external_alloc_ptes uvm_iface_get_external_alloc_phys_addrs uvm_iface_get_channel_resource_ptes uvm_iface_pma_alloc_pages uvm_iface_pma_pin_pages uvm_iface_pma_free_pages uvm_iface_csl_init_context uvm_iface_deinit_csl_context uvm_iface_csl_rotate_key uvm_iface_csl_rotate_iv uvm_iface_csl_increment_iv uvm_iface_csl_query_message_pool uvm_iface_csl_log_encryption uvm_iface_csl_encrypt uvm_iface_csl_decrypt uvm_iface_get_p2p_caps uvm_iface_csl_sign uvm_iface_access_bits_buf_alloc uvm_iface_access_bits_buf_free uvm_iface_access_bits_buf_dump uvm_iface_register_uvm_events uvm_iface_deregister_uvm_events modeset_get_rm_ops modeset_alloc_stack modeset_free_stack modeset_enumerate_gpus modeset_open_gpu modeset_close_gpu modeset_op modeset_set_callbacks modeset_register_gpu modeset_unregister_gpu modeset_notify_suspend modeset_notify_resume gpu_capabilities device_size file_size state_align device_init file_open file_close ioctl nested_plan nested_copy_error rm_preflight rm_ioctl event_selftest pci_admitted gpu_state_size gpu_state_align gpu_prepare gpu_prepare_owned gpu_software_prepare gpu_first_open gpu_pm_suspend_begin gpu_pm_suspend_rollback gpu_pm_resume_begin gpu_pm_resume_finish gpu_pm_runtime_suspend gpu_pm_runtime_resume gpu_pm_is_suspended gpu_pm_verify_alive software_manager_init software_manager_shutdown gpu_set_probe_identity gpu_registry_publish gpu_registry_retire gpu_close gpu_set_cleanup gpu_mark_removed gpu_release_driver gpu_retry_cleanup sysmem_state_size sysmem_state_align sysmem_pin_size sysmem_pin_align sysmem_prepare sysmem_allocate sysmem_info sysmem_pin sysmem_unpin sysmem_sync sysmem_close gpu_events gpu_events_retry ga10x_hwmon_poll,-u nv_rs_$(name)) -o $@
|
||||
$(OBJCOPY) --remove-section=.llvmbc --remove-section=.llvmcmd --remove-section=.eh_frame --remove-section=.eh_frame_hdr --remove-section=.gcc_except_table $@
|
||||
$(OBJCOPY) $(OBJCOPY_STRIP_FLAGS) --remove-section=.llvmbc --remove-section=.llvmcmd --remove-section=.eh_frame --remove-section=.eh_frame_hdr --remove-section=.gcc_except_table $@
|
||||
clean:
|
||||
$(RM) $(OUT)/libnv_rs_kernel.kernel.a $(OUT)/libnv_rs_kernel.a $(OUT)/nv-rust.o_binary $(OUT)/libnv_rs_abi.rlib $(OUT)/libnv_rs_core.rlib
|
||||
|
||||
|
||||
@ -106,6 +106,13 @@ pub fn detect_current_x86(vgx_build: bool) -> HypervisorType {
|
||||
})
|
||||
}
|
||||
|
||||
/// Non-x86_64 fallback (e.g., ARM64/AArch64): CPUID hypervisor leaf probing
|
||||
/// does not exist outside x86_64.
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
pub fn detect_current_x86(_vgx_build: bool) -> HypervisorType {
|
||||
HypervisorType::Unknown
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Pillar 3B: Unlocked SR-IOV / vGPU Host Hypervisor (NVIDIA 580.178.04)
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -944,4 +951,11 @@ mod tests {
|
||||
assert_eq!(mgr.detach_vgpu(&u1), NvStatus::OK);
|
||||
assert_eq!(mgr.detach_vgpu(&u1), NvStatus(0x57));
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
#[test]
|
||||
fn non_x86_hypervisor_probe_returns_unknown() {
|
||||
assert_eq!(detect_current_x86(false), HypervisorType::Unknown);
|
||||
assert_eq!(detect_current_x86(true), HypervisorType::Unknown);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import hashlib,json,os,re,shutil,struct,subprocess,sys
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
args=sys.argv[1:];obj=Path(args[0]) if args else root/'kernel-open/nvidia/nv-rust.o_binary';module=Path(args[1]) if len(args)>1 else root/'kernel-open/nvidia_rs.ko';object_only='--object-only' in args;committed_run=not args
|
||||
args=sys.argv[1:];pos=[a for a in args if a!='--object-only'];obj=Path(pos[0]) if pos else root/'kernel-open/nvidia/nv-rust.o_binary';module=Path(pos[1]) if len(pos)>1 else root/'kernel-open/nvidia_rs.ko';object_only='--object-only' in args;committed_run=not args
|
||||
# Binutils headings are parsed below; keep their output independent of the user locale.
|
||||
def run(*args):
|
||||
if args[0]=='modinfo':
|
||||
@ -49,7 +49,7 @@ for i,(n,f,inf) in enumerate(sections):
|
||||
name_map.setdefault(n,[]).append(i)
|
||||
for n,c in name_map.items():
|
||||
if len(c)>1:duplicate_names.add(n);unattributable.update(c)
|
||||
cur=None;entry=False;machine=run('readelf','-h',str(obj));x86_64='X86-64' in machine;aarch64='AArch64' in machine;naked_ret_fns=set();unhardened_sls_ret=set();prev_was_ret=False
|
||||
cur=None;entry=False;machine=run('readelf','-h',str(obj));x86_64='X86-64' in machine;aarch64='AArch64' in machine;naked_ret_fns=set();unhardened_sls_ret=set();prev_was_ret=False;has_arm64_neon_fp=False
|
||||
for line in assembly.splitlines():
|
||||
m=re.match(r'^Disassembly of section (\S+):',line)
|
||||
if m:
|
||||
@ -73,6 +73,12 @@ for line in assembly.splitlines():
|
||||
if prev_was_ret and instr!='int3':unhardened_sls_ret.add(fn)
|
||||
prev_was_ret=instr in ('ret','retq')
|
||||
if prev_was_ret:naked_ret_fns.add(fn)
|
||||
if aarch64:
|
||||
ma=re.match(r'^\s*([0-9a-f]+):\s+(?:(?:[0-9a-f]{2}\s+){4}|[0-9a-f]{8}\s+)(.+)$',line)
|
||||
if ma:
|
||||
ins=re.sub(r'\b[0-9a-f]+\s+<[^>]+>|<[^>]+>|//.*','',ma[2]).strip()
|
||||
ip=ins.split(None,1)
|
||||
if len(ip)==2 and not re.match(r'^(?:b(?:\.[a-z]+)?|bl|cbn?z|tbn?z|adrp?)$',ip[0]) and re.search(r'\b[vqdsbh](?:[0-9]|[12][0-9]|3[01])\b',ip[1]):has_arm64_neon_fp=True
|
||||
m=re.search(r'\bsub\s+\$0x([0-9a-f]+),%rsp',line)
|
||||
if m:frames[fn]=frames.get(fn,0)+int(m[1],16)
|
||||
if re.search(r'\bpush\s',line):frames[fn]=frames.get(fn,0)+8
|
||||
@ -114,7 +120,7 @@ rethunk_enforced=x86_64 and (os.environ.get('NV_RS_KERNEL_RETHUNK')=='1' or (com
|
||||
retpoline_enforced=x86_64 and (os.environ.get('NV_RS_KERNEL_RETPOLINE')=='1' or (committed_run and os.environ.get('NV_RS_KERNEL_RETPOLINE')!='0' and ('CONFIG_MITIGATION_RETPOLINE=y' in kcfg_txt or 'CONFIG_RETPOLINE=y' in kcfg_txt)))
|
||||
sls_enforced=x86_64 and (os.environ.get('NV_RS_KERNEL_SLS')=='1' or (committed_run and os.environ.get('NV_RS_KERNEL_SLS')!='0' and ('CONFIG_MITIGATION_SLS=y' in kcfg_txt or 'CONFIG_SLS=y' in kcfg_txt)))
|
||||
scs_enforced=aarch64 and (os.environ.get('NV_RS_KERNEL_SCS')=='1' or (committed_run and os.environ.get('NV_RS_KERNEL_SCS')!='0' and 'CONFIG_SHADOW_CALL_STACK=y' in kcfg_txt))
|
||||
checks={'data_relocation_targets_resolve_to_instructions':True if not ibt_enforced else not unresolved and not ambiguous_targets,'module_present':object_only or module.exists(),'no_SIMD_x87_registers':not re.search(r'%(?:[xyz]mm\d+|mm\d+|st(?:\(|\b))',assembly),'no_ARM64_NEON_FP':True if not aarch64 else not re.search(r'\b[vqds](?:[0-9]|[12][0-9]|3[01])\b',assembly),'no_ARM64_x18_clobber_under_scs':True if not scs_enforced else not re.search(r'\t(?:mov|ldr|add|sub|orr|eor|and)\s+[xw]18,',assembly),'no_naked_ret_under_rethunk':True if not rethunk_enforced else not naked_ret_fns,'no_bare_indirect_branch_under_retpoline':True if not retpoline_enforced else not re.search(r'\t(?:callq?|jmpq?)\s+\*%r',assembly),'no_unhardened_sls_return':True if not sls_enforced else not unhardened_sls_ret,'no_Rust_unwind_sections':not any('eh_frame' in n or 'gcc_except_table' in n for n,_,_ in sections),'bounded_fixed_function_stack':max(frames.values(),default=0)<=1024,'no_dynamic_RSP_subtraction':not re.search(r'\bsub\s+%[^,]+,%rsp',assembly),'no_RSP_redzone_reference':not re.search(r'-0x[\da-f]+\(%rsp\)',assembly),'endbr64_at_data_relocation_targets':True if not ibt_enforced else all(i=='endbr64' and a==0 for _,a,i in data_relocs),'protocol_exports_present':all('nv_rs_'+s in export_names for s in ['protocol_version','gpu_capabilities','event_selftest','gpu_prepare_owned','gpu_set_probe_identity','gpu_registry_publish','gpu_registry_retire','sysmem_prepare','sysmem_close'])}|({'no_unresolved_private_or_Rust_runtime_symbols':not re.search(r'\b(?:nv_rs_|_RNv|_ZN|__rust_|rust_eh_personality)',undefined),'no_unsupported_GOT_relocations':'GOT'not in reloc_text,'distinct_diagnostic_module_name':run('modinfo','-F','name',str(module)).strip()=='nvidia_rs','no_PCI_aliases':not run('modinfo','-F','alias',str(module)).strip()} if not object_only and module.exists() else {})
|
||||
checks={'data_relocation_targets_resolve_to_instructions':True if not ibt_enforced else not unresolved and not ambiguous_targets,'module_present':object_only or module.exists(),'no_SIMD_x87_registers':not re.search(r'%(?:[xyz]mm\d+|mm\d+|st(?:\(|\b))',assembly),'no_ARM64_NEON_FP':not has_arm64_neon_fp,'no_ARM64_x18_clobber_under_scs':True if not scs_enforced else not re.search(r'\t(?:mov|ldr|add|sub|orr|eor|and)\s+[xw]18,',assembly),'no_naked_ret_under_rethunk':True if not rethunk_enforced else not naked_ret_fns,'no_bare_indirect_branch_under_retpoline':True if not retpoline_enforced else not re.search(r'\t(?:callq?|jmpq?)\s+\*%r',assembly),'no_unhardened_sls_return':True if not sls_enforced else not unhardened_sls_ret,'no_Rust_unwind_sections':not any('eh_frame' in n or 'gcc_except_table' in n for n,_,_ in sections),'bounded_fixed_function_stack':max(frames.values(),default=0)<=1024,'no_dynamic_RSP_subtraction':not re.search(r'\bsub\s+%[^,]+,%rsp',assembly),'no_RSP_redzone_reference':not re.search(r'-0x[\da-f]+\(%rsp\)',assembly),'endbr64_at_data_relocation_targets':True if not ibt_enforced else all(i=='endbr64' and a==0 for _,a,i in data_relocs),'protocol_exports_present':all('nv_rs_'+s in export_names for s in ['protocol_version','gpu_capabilities','event_selftest','gpu_prepare_owned','gpu_set_probe_identity','gpu_registry_publish','gpu_registry_retire','sysmem_prepare','sysmem_close'])}|({'no_unresolved_private_or_Rust_runtime_symbols':not re.search(r'\b(?:nv_rs_|_RNv|_ZN|__rust_|rust_eh_personality)',undefined),'no_unsupported_GOT_relocations':'GOT'not in reloc_text,'distinct_diagnostic_module_name':run('modinfo','-F','name',str(module)).strip()=='nvidia_rs','no_PCI_aliases':not run('modinfo','-F','alias',str(module)).strip()} if not object_only and module.exists() else {})
|
||||
report={'passed':all(checks.values()),'checks':checks,'largest_conservative_function_stack_bytes':max(frames.values(),default=0),'ibt_gate_enforced':ibt_enforced,'functions_without_endbr':sum(1 for v in first_instr.values() if v!='endbr64'),'endbr64_at_every_function_entry_informational':bool(first_instr) and all(v=='endbr64' for v in first_instr.values()),'data_relocations_to_code':len(data_relocs),'data_relocation_targets_without_endbr':sum(1 for _,a,i in data_relocs if i!='endbr64'),'data_relocations_with_nonzero_addend':sum(1 for _,a,_ in data_relocs if a!=0),'unresolved_data_relocation_targets_in_code_sections':len(unresolved),'ambiguous_truncated_names':len(ambiguous),'unattributable_duplicate_names':len(duplicate_names),'elf_machine':re.search(r'Machine:\s+(.*)',machine).group(1).strip(),'object_sha256':hashlib.sha256(obj.read_bytes()).hexdigest(),'module_sha256':hashlib.sha256(module.read_bytes()).hexdigest() if module.exists() else None,'undefined_kernel_symbols':undefined.splitlines(),'module_checks_run':not object_only and module.exists(),'scope':'Static codegen/export checks for the current diagnostic module only. Per-function stack accounting is not a full call-chain proof; this does not prove GPU initialization, CUDA, hardware ownership or parity.'}
|
||||
if committed_run:(root/'reports/kernel-module-codegen-validation.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
print(json.dumps({'passed':report['passed'],'checks':checks,'largest_stack':report['largest_conservative_function_stack_bytes'],'functions_without_endbr':report['functions_without_endbr'],'data_relocations_to_code':report['data_relocations_to_code'],'data_relocation_targets_without_endbr':report['data_relocation_targets_without_endbr'],'data_relocations_with_nonzero_addend':report['data_relocations_with_nonzero_addend'],'unresolved_code_targets':report['unresolved_data_relocation_targets_in_code_sections'],'ambiguous_truncated_names':report['ambiguous_truncated_names'],'unattributable_duplicate_names':report['unattributable_duplicate_names'],'ibt_gate_enforced':report['ibt_gate_enforced']}));raise SystemExit(0 if report['passed']else 1)
|
||||
|
||||
16
utils.mk
16
utils.mk
@ -31,18 +31,18 @@ RUST_KERNEL_TARGET := aarch64-unknown-none
|
||||
# ARM64 kernel target (RK3588 / Ampere Altra / Apple Silicon Linux): no NEON/FP in kernel mode.
|
||||
RUST_KERNEL_FLAGS := --edition=2024 --crate-type=lib --target=$(RUST_KERNEL_TARGET) \
|
||||
--emit=obj -C opt-level=2 -C panic=abort -C relocation-model=static \
|
||||
-C code-model=small -C target-feature=-neon,-fp-armv8 -C force-frame-pointers=yes \
|
||||
-C code-model=small -C target-feature=-neon,-fp-armv8,+strict-align -C force-frame-pointers=yes \
|
||||
-C overflow-checks=yes -C debuginfo=1
|
||||
NV_RS_KERNEL_ARM64_BTI ?= $(if $(shell grep -q '^CONFIG_ARM64_BTI_KERNEL=y$$' $(KERNEL_OUTPUT)/.config 2>/dev/null && echo y),1,0)
|
||||
NV_RS_KERNEL_ARM64_PAC ?= $(if $(shell grep -q '^CONFIG_ARM64_PTR_AUTH_KERNEL=y$$' $(KERNEL_OUTPUT)/.config 2>/dev/null && echo y),1,0)
|
||||
ifeq ($(NV_RS_KERNEL_ARM64_BTI)-$(NV_RS_KERNEL_ARM64_PAC),1-1)
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=bti,pac-ret
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=bti,pac-ret -C unsafe-allow-abi-mismatch=branch-protection
|
||||
export RUSTC_BOOTSTRAP := 1
|
||||
else ifeq ($(NV_RS_KERNEL_ARM64_BTI),1)
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=bti
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=bti -C unsafe-allow-abi-mismatch=branch-protection
|
||||
export RUSTC_BOOTSTRAP := 1
|
||||
else ifeq ($(NV_RS_KERNEL_ARM64_PAC),1)
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=pac-ret
|
||||
RUST_KERNEL_FLAGS += -Z branch-protection=pac-ret -C unsafe-allow-abi-mismatch=branch-protection
|
||||
export RUSTC_BOOTSTRAP := 1
|
||||
endif
|
||||
NV_RS_KERNEL_SCS ?= $(if $(shell grep -q '^CONFIG_SHADOW_CALL_STACK=y$$' $(KERNEL_OUTPUT)/.config 2>/dev/null && echo y),1,0)
|
||||
@ -126,11 +126,15 @@ ifneq ($(shell mkdir -p $(call nv_rs_shell_quote,$(dir $(RUST_CALL_PADDING_RECEI
|
||||
$(error Cannot write Rust call-padding receipt $(RUST_CALL_PADDING_RECEIPT))
|
||||
endif
|
||||
endif
|
||||
RUST_EXTRA_FLAGS_RECEIPT := $(ROOT)/target/build-product/extra-flags.txt
|
||||
ifneq ($(shell printf '%s\n' $(call nv_rs_shell_quote,extra:$(RUST_KERNEL_EXTRA_FLAGS)) | cmp -s - $(call nv_rs_shell_quote,$(RUST_EXTRA_FLAGS_RECEIPT)) 2>/dev/null && echo ok || (mkdir -p $(call nv_rs_shell_quote,$(dir $(RUST_EXTRA_FLAGS_RECEIPT))) && printf '%s\n' $(call nv_rs_shell_quote,extra:$(RUST_KERNEL_EXTRA_FLAGS)) > $(call nv_rs_shell_quote,$(RUST_EXTRA_FLAGS_RECEIPT).tmp).$$$$ && mv -f $(call nv_rs_shell_quote,$(RUST_EXTRA_FLAGS_RECEIPT).tmp).$$$$ $(call nv_rs_shell_quote,$(RUST_EXTRA_FLAGS_RECEIPT)) && echo ok)),ok)
|
||||
$(error Cannot write Rust extra-flags receipt $(RUST_EXTRA_FLAGS_RECEIPT))
|
||||
endif
|
||||
# Explicit absolute targets work before OUT is assigned by src/nvidia/Makefile.
|
||||
# EXTRA_PREREQS preserves the original first prerequisite used by rustc $<.
|
||||
# Changed receipts invalidate every Rust artifact using these cfgs or padding flags.
|
||||
# Changed receipts invalidate every Rust artifact using these cfgs, padding, or extra flags.
|
||||
NV_RS_PRIOR_DEFAULT_GOAL := $(.DEFAULT_GOAL)
|
||||
$(ROOT)/kernel-open/nvidia/libnv_rs_abi.rlib \
|
||||
$(ROOT)/kernel-open/nvidia/libnv_rs_core.rlib \
|
||||
$(ROOT)/kernel-open/nvidia/libnv_rs_kernel.a: .EXTRA_PREREQS := $(RUST_BUILD_PRODUCT_RECEIPT) $(RUST_CALL_PADDING_RECEIPT)
|
||||
$(ROOT)/kernel-open/nvidia/libnv_rs_kernel.a: .EXTRA_PREREQS := $(RUST_BUILD_PRODUCT_RECEIPT) $(RUST_CALL_PADDING_RECEIPT) $(RUST_EXTRA_FLAGS_RECEIPT)
|
||||
.DEFAULT_GOAL := $(NV_RS_PRIOR_DEFAULT_GOAL)
|
||||
|
||||
Reference in New Issue
Block a user