Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153969465
D56520.id175986.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
19 KB
Referenced Files
None
Subscribers
None
D56520.id175986.diff
View Options
diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c
--- a/sys/arm64/arm64/busdma_bounce.c
+++ b/sys/arm64/arm64/busdma_bounce.c
@@ -36,6 +36,7 @@
#include <sys/domainset.h>
#include <sys/malloc.h>
#include <sys/bus.h>
+#include <sys/busdma_bufalloc.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
@@ -56,6 +57,7 @@
#include <machine/atomic.h>
#include <machine/bus.h>
#include <machine/md_var.h>
+#include <machine/rsi.h>
#include <arm64/include/bus_dma_impl.h>
#define MAX_BPAGES 4096
@@ -120,6 +122,8 @@
static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
vm_paddr_t buf, bus_size_t buflen, int flags);
+static busdma_bufalloc_t nonsecure_allocator;
+
static MALLOC_DEFINE(M_BUSDMA, "busdma", "busdma metadata");
#define dmat_alignment(dmat) ((dmat)->common.alignment)
@@ -215,6 +219,10 @@
if (map && (map->flags & DMAMAP_FROM_DMAMEM) != 0)
return (false);
+ /* Bounce if accessing secure memory */
+ if (in_realm() && !(paddr & prot_ns_shared))
+ return (true);
+
if ((dmat->bounce_flags & BF_COULD_BOUNCE) != 0)
return (true);
@@ -239,6 +247,10 @@
addr_needs_bounce(dmat, paddr))
return (true);
+ /* Bounce if accessing secure memory */
+ if (in_realm() && !(paddr & prot_ns_shared))
+ return (true);
+
return (false);
}
@@ -492,6 +504,7 @@
bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
bus_dmamap_t *mapp)
{
+ struct busdma_bufzone *bufzone;
vm_memattr_t attr;
int mflags;
@@ -524,6 +537,9 @@
else
attr = VM_MEMATTR_DEFAULT;
+ if (in_realm())
+ mflags |= M_UNPROTECTED;
+
/*
* Create the map, but don't set the could bounce flag as
* this allocation should never bounce;
@@ -567,13 +583,16 @@
*
* In the meantime warn the user if malloc gets it wrong.
*/
- if (dmat->alloc_size <= PAGE_SIZE &&
+
+ bufzone = busdma_bufalloc_findzone(nonsecure_allocator,
+ dmat->alloc_size);
+
+ if (bufzone &&
+ dmat->alloc_size <= PAGE_SIZE &&
dmat->alloc_alignment <= PAGE_SIZE &&
dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
attr == VM_MEMATTR_DEFAULT) {
- *vaddr = malloc_domainset_aligned(dmat->alloc_size,
- dmat->alloc_alignment, M_DEVBUF,
- DOMAINSET_PREF(dmat->common.domain), mflags);
+ *vaddr = uma_zalloc(bufzone->umazone, mflags);
} else if (dmat->common.nsegments >=
howmany(dmat->alloc_size, MIN(dmat->common.maxsegsz, PAGE_SIZE)) &&
dmat->alloc_alignment <= PAGE_SIZE &&
@@ -1150,3 +1169,44 @@
.load_kmsan = bounce_bus_dmamap_load_kmsan,
#endif
};
+
+static void *
+nonsecure_alloc(uma_zone_t zone, vm_size_t size, int domain, uint8_t *pflag,
+ int wait)
+{
+ void *p; /* Returned page */
+
+ *pflag = UMA_SLAB_KERNEL;
+ p = kmem_malloc_domainset(DOMAINSET_FIXED(domain), size,
+ wait | M_UNPROTECTED);
+
+ return (p);
+}
+
+static void
+nonsecure_free(void *mem, vm_size_t size, uint8_t flags)
+{
+ KASSERT((flags & UMA_SLAB_KERNEL) != 0,
+ ("UMA: page_free used with invalid flags %x", flags));
+
+ kmem_free(mem, size);
+}
+
+static void
+busdma_bounce_init(void *dummy)
+{
+ if (in_realm())
+ nonsecure_allocator = busdma_bufalloc_create("nonsecure",
+ dcache_line_size, /* minimum_alignment */
+ nonsecure_alloc, /* uma_alloc func */
+ nonsecure_free, /* uma_free func */
+ UMA_ZONE_NOTOUCH); /* uma_zcreate_flags */
+ else
+ nonsecure_allocator = busdma_bufalloc_create("nonsecure",
+ dcache_line_size, /* minimum_alignment */
+ NULL, /* uma_alloc func */
+ NULL, /* uma_free func */
+ UMA_ZONE_NOTOUCH); /* uma_zcreate_flags */
+}
+
+SYSINIT(busdma, SI_SUB_KMEM + 1, SI_ORDER_FIRST, busdma_bounce_init, NULL);
diff --git a/sys/arm64/arm64/efirt_machdep.c b/sys/arm64/arm64/efirt_machdep.c
--- a/sys/arm64/arm64/efirt_machdep.c
+++ b/sys/arm64/arm64/efirt_machdep.c
@@ -46,6 +46,7 @@
#include <sys/vmmeter.h>
#include <machine/pte.h>
+#include <machine/rsi.h>
#include <machine/vmparam.h>
#include <vm/vm.h>
@@ -227,6 +228,9 @@
if (mode == VM_MEMATTR_DEVICE || p->md_attr & EFI_MD_ATTR_XP)
l3_attr |= ATTR_S1_XN;
+ if (mode == VM_MEMATTR_DEVICE && in_realm())
+ l3_attr |= prot_ns_shared;
+
VM_OBJECT_WLOCK(obj_1t1_pt);
for (va = p->md_phys, idx = 0; idx < p->md_pages;
idx += (PAGE_SIZE / EFI_PAGE_SIZE), va += PAGE_SIZE) {
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -799,7 +799,7 @@
adrp x9, socdev_va
str x17, [x9, :lo12:socdev_va]
- mov x9, #(SOCDEV_PA & ~L2_OFFSET) /* PA start */
+ ldr x9, =(SOCDEV_PA) /* PA start */
mov x10, #1
bl build_l2_block_pagetable
#endif
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -86,6 +86,7 @@
#include <machine/metadata.h>
#include <machine/md_var.h>
#include <machine/pcb.h>
+#include <machine/rsi.h>
#include <machine/undefined.h>
#include <machine/vmparam.h>
@@ -103,6 +104,7 @@
#include <dev/ofw/openfirm.h>
#endif
+#include <dev/psci/psci.h>
#include <dev/smbios/smbios.h>
_Static_assert(sizeof(struct pcb) == 1248, "struct pcb is incorrect size");
@@ -890,6 +892,9 @@
valid = bus_probe();
+ psci_init(NULL);
+ arm64_rsi_setup_memory();
+
cninit();
set_ttbr0(abp->kern_ttbr0);
pmap_s1_invalidate_all_kernel();
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -152,6 +152,7 @@
#include <machine/machdep.h>
#include <machine/md_var.h>
#include <machine/pcb.h>
+#include <machine/rsi.h>
#ifdef NUMA
#define PMAP_MEMDOM MAXMEMDOM
@@ -537,6 +538,9 @@
static void pmap_bti_deassign_all(pmap_t pmap);
static void pagezero(void *);
+static void pmap_set_protected(pt_entry_t old_l3);
+static void pmap_set_unprotected(pt_entry_t new_l3);
+
/*
* These load the old table data and store the new value.
* They need to be atomic as the System MMU may write to the table at
@@ -2367,6 +2371,11 @@
KASSERT((size & PAGE_MASK) == 0,
("pmap_kenter: Mapping is not page-sized"));
+ /* CCA - Map devices as nonsecure */
+ if (in_realm() && (mode == VM_MEMATTR_DEVICE ||
+ mode == VM_MEMATTR_DEVICE_NP))
+ pa |= prot_ns_shared;
+
attr = ATTR_AF | pmap_sh_attr | ATTR_S1_AP(ATTR_S1_AP_RW) |
ATTR_S1_XN | ATTR_KERN_GP | ATTR_S1_IDX(mode);
old_l3e = 0;
@@ -4208,6 +4217,8 @@
if ((old_l3 & ATTR_SW_WIRED) != 0)
pmap->pm_stats.wired_count--;
pmap_resident_count_dec(pmap, 1);
+ if (in_realm() && (old_l3 & prot_ns_shared))
+ pmap_set_protected(old_l3);
if ((old_l3 & ATTR_SW_MANAGED) != 0) {
m = PTE_TO_VM_PAGE(old_l3);
if (pmap_pte_dirty(pmap, old_l3))
@@ -5360,6 +5371,28 @@
return (KERN_SUCCESS);
}
+static void
+pmap_set_unprotected(pt_entry_t new_l3)
+{
+ vm_paddr_t pa;
+
+ pa = PTE_TO_PHYS(new_l3) & ~prot_ns_shared;
+
+ rsi_set_addr_range_state(pa, pa + L3_SIZE, RSI_RIPAS_EMPTY,
+ RSI_CHANGE_DESTROYED, NULL);
+}
+
+static void
+pmap_set_protected(pt_entry_t old_l3)
+{
+ vm_paddr_t pa;
+
+ pa = PTE_TO_PHYS(old_l3) & ~prot_ns_shared;
+
+ rsi_set_addr_range_state(pa, pa + L3_SIZE, RSI_RIPAS_RAM,
+ RSI_CHANGE_DESTROYED, NULL);
+}
+
/*
* Insert the given physical page (p) at
* the specified virtual address (v) in the
@@ -5399,6 +5432,8 @@
new_l3 |= pmap_pte_prot(pmap, prot);
if ((flags & PMAP_ENTER_WIRED) != 0)
new_l3 |= ATTR_SW_WIRED;
+ if (in_realm() && (flags & PMAP_ENTER_UNPROTECTED) != 0)
+ new_l3 |= prot_ns_shared;
if (pmap->pm_stage == PM_STAGE1) {
if (ADDR_IS_USER(va))
new_l3 |= ATTR_S1_AP(ATTR_S1_AP_USER) | ATTR_S1_PXN;
@@ -5714,6 +5749,10 @@
rv = KERN_SUCCESS;
out:
+ if (in_realm() && (flags & PMAP_ENTER_UNPROTECTED) != 0 &&
+ rv == KERN_SUCCESS)
+ pmap_set_unprotected(new_l3);
+
if (lock != NULL)
rw_wunlock(lock);
PMAP_UNLOCK(pmap);
diff --git a/sys/arm64/arm64/rsi.c b/sys/arm64/arm64/rsi.c
new file mode 100644
--- /dev/null
+++ b/sys/arm64/arm64/rsi.c
@@ -0,0 +1,189 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Arm Ltd
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "opt_acpi.h"
+#include "opt_platform.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/physmem.h>
+#include <sys/rwlock.h>
+
+#include <vm/vm_page.h>
+
+#include <machine/rsi.h>
+#include <machine/vmparam.h>
+
+#include <dev/psci/psci.h>
+#include <dev/psci/smccc.h>
+
+#ifdef FDT
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#endif
+
+#ifdef DEV_ACPI
+#include <contrib/dev/acpica/include/acpi.h>
+#include <dev/acpica/acpivar.h>
+#endif
+
+static struct realm_config config;
+static bool rsi_present = false;
+
+uint64_t prot_ns_shared;
+
+#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
+
+static vm_paddr_t physmap[PHYSMAP_SIZE];
+
+static unsigned long rsi_request_version(unsigned long req,
+ unsigned long *out_lower, unsigned long *out_higher)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SMC_RSI_ABI_VERSION, req, 0, 0, 0, 0, 0, 0, &res);
+
+ if (out_lower)
+ *out_lower = res.a1;
+ if (out_higher)
+ *out_higher = res.a2;
+
+ return (res.a0);
+}
+
+static inline unsigned long
+rsi_get_realm_config(struct realm_config *cfg)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SMC_RSI_REALM_CONFIG, vtophys(cfg), 0, 0, 0, 0, 0, 0,
+ &res);
+ return (res.a0);
+}
+
+static bool
+rsi_version_matches(void)
+{
+ unsigned long ver_lower, ver_higher;
+ unsigned long ret;
+
+ ret = rsi_request_version(RSI_ABI_VERSION, &ver_lower, &ver_higher);
+
+ if (ret == SMCCC_RET_NOT_SUPPORTED)
+ return (false);
+
+ if (ret != RSI_SUCCESS) {
+ printf("RME: RMM doesn't support RSI version %lu.%lu. Supported range: %lu.%lu-%lu.%lu\n",
+ RSI_ABI_VERSION_MAJOR, RSI_ABI_VERSION_MINOR,
+ RSI_ABI_VERSION_GET_MAJOR(ver_lower),
+ RSI_ABI_VERSION_GET_MINOR(ver_lower),
+ RSI_ABI_VERSION_GET_MAJOR(ver_higher),
+ RSI_ABI_VERSION_GET_MINOR(ver_higher));
+ return (false);
+ }
+
+ printf("RME: Using RSI version %lu.%lu\n",
+ RSI_ABI_VERSION_GET_MAJOR(ver_lower),
+ RSI_ABI_VERSION_GET_MINOR(ver_lower));
+
+ return (true);
+}
+
+
+unsigned long rsi_set_addr_range_state(vm_paddr_t start, vm_paddr_t end,
+ enum ripas state, unsigned long flags, vm_paddr_t *top)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SMC_RSI_IPA_STATE_SET, start, end, state, flags, 0, 0, 0,
+ &res);
+
+ if (top)
+ *top = res.a1;
+
+ return (res.a0);
+}
+
+static int rsi_set_memory_range(vm_paddr_t start, vm_paddr_t end,
+ enum ripas state, unsigned long flags)
+{
+ unsigned long ret;
+ vm_paddr_t top;
+
+ while (start != end) {
+ ret = rsi_set_addr_range_state(start, end, state, flags, &top);
+ if (ret || top < start || top > end)
+ return (-EINVAL);
+ start = top;
+ }
+
+ return (0);
+}
+
+/*
+ * Convert the specified range to RAM. Do not convert any pages that may have
+ * been DESTROYED, without our permission.
+ */
+static int rsi_set_memory_range_protected_safe(vm_paddr_t start, vm_paddr_t end)
+{
+ return (rsi_set_memory_range(start, end, RSI_RIPAS_RAM,
+ RSI_NO_CHANGE_DESTROYED));
+}
+
+void
+arm64_rsi_setup_memory(void)
+{
+ int physmap_idx;
+ int i;
+
+ if (!psci_conduit_is_smc())
+ return;
+ if (!rsi_version_matches())
+ return;
+ if (rsi_get_realm_config(&config))
+ return;
+
+ prot_ns_shared = 1ul << (config.ipa_bits - 1);
+ printf("arm64_rsi_setup_memory: rsi_present, ipa_bits=%lu prot_ns_shared=%lx\n",
+ config.ipa_bits, prot_ns_shared);
+ rsi_present = true;
+
+ physmap_idx = physmem_avail(physmap, nitems(physmap));
+
+ printf("physmap:\n");
+ for (i = 0; i < physmap_idx; i += 2) {
+ printf(" %lx %lx\n", physmap[i], physmap[i + 1]);
+ if (rsi_set_memory_range_protected_safe(physmap[i],
+ physmap[i + 1]))
+ panic("rsi_set_memory_range_protected_safe failed");
+ }
+}
+
+bool in_realm(void)
+{
+ return (rsi_present);
+}
diff --git a/sys/arm64/include/rsi.h b/sys/arm64/include/rsi.h
new file mode 100644
--- /dev/null
+++ b/sys/arm64/include/rsi.h
@@ -0,0 +1,129 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Arm Ltd
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_RSI_H_
+#define _MACHINE_RSI_H_
+
+extern uint64_t prot_ns_shared;
+
+bool in_realm(void);
+
+void arm64_rsi_setup_memory(void);
+
+/*
+ * The major version number of the RSI implementation. This is increased when
+ * the binary format or semantics of the SMC calls change.
+ */
+#define RSI_ABI_VERSION_MAJOR UL(1)
+
+/*
+ * The minor version number of the RSI implementation. This is increased when
+ * a bug is fixed, or a feature is added without breaking binary compatibility.
+ */
+#define RSI_ABI_VERSION_MINOR UL(0)
+
+#define RSI_ABI_VERSION ((RSI_ABI_VERSION_MAJOR << 16) | \
+ RSI_ABI_VERSION_MINOR)
+
+#define RSI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16)
+#define RSI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFF)
+
+#define RSI_SUCCESS UL(0)
+#define RSI_ERROR_INPUT UL(1)
+#define RSI_ERROR_STATE UL(2)
+#define RSI_INCOMPLETE UL(3)
+#define RSI_ERROR_UNKNOWN UL(4)
+
+#define SMC_RSI_FID(n) SMCCC_FUNC_ID(SMCCC_FAST_CALL, \
+ SMCCC_64BIT_CALL, \
+ SMCCC_STD_SECURE_SERVICE_CALLS, \
+ n)
+
+/*
+ * Returns RSI version.
+ *
+ * arg1 == Requested interface revision
+ * ret0 == Status / error
+ * ret1 == Lower implemented interface revision
+ * ret2 == Higher implemented interface revision
+ */
+#define SMC_RSI_ABI_VERSION SMC_RSI_FID(0x190)
+
+/*
+ * Read configuration for the current Realm.
+ *
+ * arg1 == struct realm_config addr
+ * ret0 == Status / error
+ */
+#define SMC_RSI_REALM_CONFIG SMC_RSI_FID(0x196)
+
+struct realm_config {
+ union {
+ struct {
+ unsigned long ipa_bits; /* Width of IPA in bits */
+ unsigned long hash_algo; /* Hash algorithm */
+ };
+ uint8_t pad[0x200];
+ };
+ union {
+ uint8_t rpv[64]; /* Realm Personalization Value */
+ uint8_t pad2[0xe00];
+ };
+ /*
+ * The RMM requires the configuration structure to be aligned to a 4k
+ * boundary, ensure this happens by aligning this structure.
+ */
+} __aligned(0x1000);
+
+/*
+ * Request RIPAS of a target IPA range to be changed to a specified value.
+ *
+ * arg1 == Base IPA address of target region
+ * arg2 == Top of the region
+ * arg3 == RIPAS value
+ * arg4 == flags
+ * ret0 == Status / error
+ * ret1 == Top of modified IPA range
+ * ret2 == Whether the Host accepted or rejected the request
+ */
+#define SMC_RSI_IPA_STATE_SET SMC_RSI_FID(0x197)
+
+#define RSI_NO_CHANGE_DESTROYED UL(0)
+#define RSI_CHANGE_DESTROYED UL(1)
+
+#define RSI_ACCEPT UL(0)
+#define RSI_REJECT UL(1)
+
+enum ripas {
+ RSI_RIPAS_EMPTY = 0,
+ RSI_RIPAS_RAM
+};
+
+unsigned long rsi_set_addr_range_state(vm_paddr_t start, vm_paddr_t end,
+ enum ripas state, unsigned long flags, vm_paddr_t *top);
+
+#endif /* !_MACHINE_RSI_H_ */
diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64
--- a/sys/conf/files.arm64
+++ b/sys/conf/files.arm64
@@ -9,6 +9,7 @@
kern/subr_efi_map.c standard
kern/subr_intr.c optional intrng
kern/subr_physmem.c standard
+kern/subr_busdma_bufalloc.c standard
libkern/strlen.c standard
libkern/arm64/crc32c_armv8.S standard
@@ -77,6 +78,7 @@
compile-with "${NORMAL_C:N-mbranch-protection*} -mbranch-protection=bti"
arm64/arm64/pmap.c standard
arm64/arm64/ptrace_machdep.c standard
+arm64/arm64/rsi.c standard
arm64/arm64/sdt_machdep.c optional kdtrace_hooks
arm64/arm64/sigtramp.S standard
arm64/arm64/spec_workaround.c standard
diff --git a/sys/dev/psci/psci.h b/sys/dev/psci/psci.h
--- a/sys/dev/psci/psci.h
+++ b/sys/dev/psci/psci.h
@@ -44,6 +44,11 @@
int32_t psci_features(uint32_t);
int psci_get_version(void);
+#ifdef __aarch64__
+void psci_init(void *dummy);
+bool psci_conduit_is_smc(void);
+#endif
+
/* Handler to let us call into the PSCI/SMCCC firmware */
extern psci_callfn_t psci_callfn;
static inline int
diff --git a/sys/dev/psci/psci.c b/sys/dev/psci/psci.c
--- a/sys/dev/psci/psci.c
+++ b/sys/dev/psci/psci.c
@@ -133,7 +133,7 @@
psci_callfn_t psci_callfn = psci_def_callfn;
-static void
+void
psci_init(void *dummy)
{
psci_callfn_t new_callfn;
@@ -146,8 +146,11 @@
psci_callfn = new_callfn;
psci_present = true;
}
+
+#ifdef __arm__
/* This needs to be before cpu_mp at SI_SUB_CPU, SI_ORDER_THIRD */
SYSINIT(psci_start, SI_SUB_CPU, SI_ORDER_FIRST, psci_init, NULL);
+#endif
static int
psci_def_callfn(register_t a __unused, register_t b __unused,
@@ -631,3 +634,9 @@
device_printf(dev, "PSCI version number mismatched with DT\n");
return (1);
}
+
+bool
+psci_conduit_is_smc(void)
+{
+ return (psci_callfn == arm_smccc_smc);
+}
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -110,6 +110,9 @@
#include <vm/uma_int.h>
#include <machine/md_var.h>
+#if defined(__aarch64__)
+#include <machine/rsi.h>
+#endif
struct vm_domain vm_dom[MAXMEMDOM];
@@ -1290,6 +1293,10 @@
vm_page_t m;
#ifdef VM_PHYSSEG_SPARSE
+#if defined(__aarch64__)
+ if (in_realm())
+ pa &= ~prot_ns_shared; /* Mask off secure bit */
+#endif
m = vm_phys_paddr_to_vm_page(pa);
if (m == NULL)
m = vm_phys_fictitious_to_vm_page(pa);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 26, 4:29 AM (20 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32039439
Default Alt Text
D56520.id175986.diff (19 KB)
Attached To
Mode
D56520: arm64: Add CCA guest support
Attached
Detach File
Event Timeline
Log In to Comment