Commit graph

2299 commits

Author SHA1 Message Date
Kyle Evans
9c2aaaa997 arm64: lop off another 24MB of KVA for early device mappings
This grows the block enough to fit a 4K 32-bit depth framebuffer; some
firmware would present smaller GOP modes to be able to boot with a
smaller framebuffer on these devices, but the Windows Devkit firmware
is simply not that nice.  Instead, it offers exactly one GOP mode that
matches the current resolution of the attached display, so with limited
control over resolution on most of my displays it'd be nice if we could
Just Work(TM) at 4K.

andrew notes that he has some ideas for removing PMAP_MAPDEV_EARLY_SIZE
entirely, so this limitation could end up removed altogether in the
future.

Reviewed by:	andrew, emaste

(cherry picked from commit a3ceeef26bc880b86f4e181bddd9924a2b5e0691)
2023-12-14 18:58:08 -06:00
Brooks Davis
3ad2fd6fb1 makesyscalls: don't make syscall.mk by default
We only want to produce syscall.mk for the main syscall table so default
to not producing it (send it to /dev/null) and add a syscalls.conf to
sys/kern to trigger the creation of sys/sys/syscall.mk.  This eliminates
the need for entries in other syscalls.conf files and is a cleaner
pattern going forward.

Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D42663

(cherry picked from commit 54d487c4d01d68ef0ac03eae1fc574f7533d46f6)
2023-12-13 23:07:06 +00:00
Mark Johnston
4161f141aa arm64: Add register definitions for MDCR_EL2
This is needed to support the bhyve gdb stub implementation on arm64.

Reviewed by:	andrew
MFC after:	1 week
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D42867

(cherry picked from commit 4f12883c360dbb03562f11713e711e3a3a330a0f)
2023-12-08 09:23:52 -05:00
Mitchell Horne
165cc0eea9 busdma: emit a warning for use of filters
Filter functions are deprecated, and unused in the tree. If either of
the filter or filterarg arguments to bus_dma_tag_create() are non-NULL,
print a warning.

This is a direct commit to stable/14.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42897
2023-12-06 19:23:14 -04:00
Konstantin Belousov
608e56cfe9 FEATURE compat_freebsd_32bit: only report on arm64 when support is present
(cherry picked from commit 5a2bbacea56f40e91c5371d5d6a210afd797fd3b)
2023-11-28 13:39:38 +02:00
Mark Johnston
5a86ae15f0 arm64: Initialize x18 for APs earlier during boot
When KMSAN is configured, the instrumentation inserts calls to
__msan_get_context_state() into all function prologues.  The
implementation dereferences curthread and thus assumes that x18 points
to the PCPU area.  This applies in particular to init_secondary(), which
currently is responsible for initializing x18 for APs.

Move initialization into locore to avoid this problem.  No functional
change intended.

Reviewed by:	kib, andrew
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D42533

(cherry picked from commit b9c0003f0fa39ead4bb3953b9118ae6f08e560f8)
2023-11-27 10:09:04 -05:00
Konstantin Belousov
5889b1f052 arm64: do not register elf32 brand if hardware cannot exec aarch32
(cherry picked from commit 0aa93010c571b88a6402405be22745fa05a5baab)
2023-11-23 06:00:36 +02:00
Konstantin Belousov
e4fb49e867 Fix typo
(cherry picked from commit d093fe94e10f88fb5f46108f28555584f2f90d08)
2023-11-10 14:15:46 +02:00
Konstantin Belousov
0dc8af9dae arm64: improve UVA layout for 32bit processes
PR:	274705

(cherry picked from commit 967022aa5aa60a18764a668ae0fb78e39e16fa8e)
2023-11-10 14:15:46 +02:00
Andrew Turner
c21038f552 arm64: Use the Linux sigframe to restore registers
When returning from a Linux signal use the Linux sigframe to find the
register values to restore.

Remove the FreeBSD ucontext from the stack as it's now unneeded.

PR:		270250
Reviewed by:	dchagin, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42360

(cherry picked from commit 070a4ff82a34652d533f9315ae9ad0aa8f1fdeb2)
2023-11-06 18:12:23 +03:00
Mark Johnston
2d49b111a3 uiomove: Add some assertions
Make sure that we don't try to copy with a negative resid.

Make sure that we don't walk off the end of the iovec array.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42098

(cherry picked from commit 8fd0ec53deaad34383d4b344714b74d67105b258)
2023-10-24 09:19:01 -04:00
Bojan Novković
ab6bc4893e arm64: Add a leaf PTP when pmap_enter(psind=1) creates a wired mapping
Let pmap_enter_l2() create wired mappings.  In particular, allocate a
leaf PTP for use during demotion.  This is a step towards reverting
commit 64087fd7f3.

Reviewed by:	alc, markj
Sponsored by:	Google, Inc. (GSoC 2023)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D41634

(cherry picked from commit 808f5ac3c6dcbe38f505c0c843b0a10ae154e6ec)
2023-10-24 09:17:37 -04:00
Konstantin Belousov
1c02fbf230 arm64, risvc: warn about ignored kstack_pages for thread0
(cherry picked from commit 6aa641b71d0dd1b26674f0b6dba086410f643595)
2023-10-20 18:55:45 +03:00
Konstantin Belousov
3f5b4dd6cd arm64, riscv: Use KSTACK_PAGES for the thread0 kstack size designator
(cherry picked from commit ac63f7534d0102352bf993ebe2c748ce2ffd432e)
2023-10-20 18:55:45 +03:00
Konstantin Belousov
e857fe2227 arm64 locore.S: fix typos
(cherry picked from commit 4095e0bcb9e8fac51eedad89211a5b16af7f55ad)
2023-10-20 18:55:44 +03:00
Olivier Houchard
0e0a03c792 arm64/compat32: Fix handling of 32bits FP registers.
We must consider the aarch32 FP registers as 16 128bits registers, and store
that as the first 16 aarch64 FP registers.

PR: 267788

(cherry picked from commit ccd0f34d8585cba727dd17a381309855af655b82)
2023-10-19 18:45:17 -04:00
Emmanuel Vadot
fd4760cbda arm64: rockchip: rk_clk_composite: Remove gate code
It was a bad idea to have composite clock directly managing gates.
All clocks drivers have been rewrite to not use this functionality
and directly export the gate. We can now remove this code.

(cherry picked from commit db34f02028f30bbf099bf1bce7ce66184f51b332)
2023-10-18 16:33:35 +02:00
Emmanuel Vadot
57209137eb arm64: rockchip: rk3399_pmucru: Finish exporting all clocks
- All used clocks are now exported.
- Use the macros from rk_cru.h so code is similar to other rk clock drivers.

(cherry picked from commit 829b06ad8f6f3317777c2395a090a898fdcd550c)
2023-10-18 16:33:33 +02:00
Emmanuel Vadot
66765585ab arm64: rockchip: Remove CRU_GATE macro
It's unused now

(cherry picked from commit 5b7fe78032a0d07995c1c1c005d82c3a1fe8a056)
2023-10-18 16:33:32 +02:00
Emmanuel Vadot
1469218c9c arm64: rockchip: rk3399_pmucru: Use GATE macro
It make it easier to read the code and the register number

(cherry picked from commit 3d2ccc352db54b9fb11c4c1373a577e3e9d25114)
2023-10-18 16:33:31 +02:00
Emmanuel Vadot
14652ce3f5 arm64: rockchip: rk3328_cru: Use GATE macro
It make it easier to read the code and the register number

(cherry picked from commit 7c6c426f29831799d1eae1ca5d4036a219b52fca)
2023-10-18 16:33:29 +02:00
Emmanuel Vadot
4bb49357e0 arm64: rockchip: rk3568_cru: Rewrite
Rewrite correctly the clocks for cru :
- Export all clocks
- Use names from the TRM
- Respect clock topology

Fixes:  a48301a5e0 ("Add initial clocks support for Rockchip RK3568 SoC.")
(cherry picked from commit 50a0f1ce28b7f04fc23915fb06124242632a013c)
2023-10-18 16:33:28 +02:00
Emmanuel Vadot
90b135d8c2 arm64: rockchip: rk3568_pmucru: Rewrite
Rewrite correctly the clocks for pmucru :
- Export all clocks
- Use names from the TRM
- Respect clock topology

Fixes:	a48301a5e0 ("Add initial clocks support for Rockchip RK3568 SoC.")
(cherry picked from commit 7b6ae431cf70cd8683270b3e315a14e61d666522)
2023-10-18 16:33:26 +02:00
Emmanuel Vadot
dda809fb31 arm64: rockchip: clk: Define PLIST macro in rk_cru.h
We use it in all clock drivers so no need to define it everywhere

(cherry picked from commit 8ae54db63970e9370d3d88f6eb57c102e085a128)
2023-10-18 16:33:25 +02:00
Emmanuel Vadot
7b824791e7 i2c: Add cadence iic driver
This IP is found in Xilinx SoC, it only been tested on ZynqMP (arm64)
so only enable it there for now.

Differential Revision:	https://reviews.freebsd.org/D41994

(cherry picked from commit 137b58e4d2044adc200d13c8989d3746a0a4bd7f)
2023-10-18 16:32:17 +02:00
Dmitry Chagin
133ada6bff linux(4): Drop the outdated comment, nosys is fine since 39024a89
MFC after:		1 week

(cherry picked from commit 03f5bd1e462576838e79145379ce314e2e03e4b3)
2023-10-18 08:52:33 +03:00
John Baldwin
842a945c40 efirt_machdep.c: Trim some unused includes
Reviewed by:	imp, kib, markj
Differential Revision:	https://reviews.freebsd.org/D41596

(cherry picked from commit d1e4c63d9e93b113f7ef5aef5e0e79a4d7dca144)
2023-10-11 08:10:32 -07:00
Dmitry Chagin
a4b328aa41 linux(4): Regen for linux_nosys change
MFC after:		1 week

(cherry picked from commit 99abee8b7be2d19be583b942b470f7af11d32ddc)
2023-10-10 08:12:12 +03:00
Dmitry Chagin
ea54d65b34 linux(4): Deorbit linux_nosys from syscalls.master
Differential Revision:	https://reviews.freebsd.org/D41902
MFC after:		1 week

(cherry picked from commit 8e523be5a5a2cb9660021d2de5732ee7257b2788)
2023-10-10 08:12:12 +03:00
Konstantin Belousov
45ebb15ab1 sysentvec: add SV_SIGSYS flag
(cherry picked from commit b82b4ae752501469053979393e33bbfa74fbc9d2)
2023-10-09 06:24:31 +03:00
Konstantin Belousov
e0f1021386 syscalls: fix missing SIGSYS for several ENOSYS errors
(cherry picked from commit 39024a89146902ca9aba250130b828ad9aced99d)
2023-10-09 06:24:31 +03:00
Dmitry Chagin
6f63d749fe linux(4): Regen
MFC after:		1 week

(cherry picked from commit 28035f675b8590a24fddb418083788609ef75cc8)
2023-10-02 08:44:53 +03:00
Dmitry Chagin
4d46ca6550 linux(4): Update syscalls.master to 6.5
MFC after:		1 week

(cherry picked from commit 0a16d3d14db67c89ee08f954c670ec4f447a7ab5)
2023-10-02 08:44:53 +03:00
Andrew Turner
caf7bc5356 arm64: Fix errata workarounds that depend on smccc
Some arm64 errata depend on calling into the firmware via the SMCCC
interface. This needs to happen after the psci driver has attached
as they share the interface.

Fix this by allowing the workarounds to mark when they depend on
device drivers attaching.

This is only an issue on CPU 0 as the workarounds are applied later
for the non-boot CPUs.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41916

(cherry picked from commit c643e82dba0b17b2716de4c9d44a3c9c547cbbd5)
(cherry picked from commit 843bea18711d726cd2f0a3c3f9144b218e4de3e8)
2023-09-25 12:01:28 +00:00
Andrew Turner
fc7460a5ca gicv3: Add logging for when its_device_alloc fails
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41566

(cherry picked from commit 5429e194212e7d2fd7b4771bcf348f0917a0d505)
2023-09-25 12:01:28 +00:00
Andrew Turner
fce3bc6b46 gicv3: Support indirect ITS tables
The GICv3 ITS device supports two options for device tables. Currently
we support a single table to hold all device IDs, however when the
device ID space grows large this can be too large for the GITS_BASER
register to describe.

To handle this case, and to reduce the memory needed when this space
is sparse support the second option, the indirect table. The indirect
table is a 2 level table where the first level contains the physical
address of the second with a valid bit. The second level is an ITS
page sized table where each entry is the original entry size.

As we don't need to allocate a second level table for devices IDs that
don't exist this can reduce the allocation size.

Reviewed by:	gallatin
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41555

(cherry picked from commit 8b143276ae493c8f060159643d9d9cdc149e294a)
2023-09-25 12:01:28 +00:00
Dmitry Chagin
058e9c13e3 linux(4): Cleanup dummy syscall list on arm64
These syscalls do not exist on arm64 Linux.

MFC after:		1 week

(cherry picked from commit d0266fbab9b8eafc1aedffbedf66dedb4774794c)
2023-09-25 13:18:54 +03:00
Dmitry Chagin
cce0625cdf linux(4): Cleanup includes under arm64
No functional changes.

MFC after:		1 week

(cherry picked from commit 027d727d4071435376017d3789fe603a8aec805a)
2023-09-24 13:51:36 +03:00
Dmitry Chagin
e68a2f18b6 linux(4): Validate exec_setregs on arm64
The lr register is cleared at the beginning of the _dl_start and _start,
so there is no need to initialize it.
Gnu libc _start takes an rtld_fini pointer in x0 which is set by ld.so
for __libc_start_main, the kernel does not register any atexit pointers.

While here fix whitespaces.

MFC after:		1 week

(cherry picked from commit 20845a6994c548977874d1f413044d43c8474f0a)
2023-09-24 13:51:36 +03:00
Dmitry Chagin
a321b17b8e linux(4): Deduplicate mmap2
To help porting the Linux emulation layer to a new platforms start using
Linux names for conditional builds instead of architecture-specific ifdefs.

MFC after:		1 week

(cherry picked from commit 2a1cf1b6b55c8326bbe85d0fdf17b0f2fb9b34ce)
2023-09-12 10:48:56 +03:00
Dmitry Chagin
4d17239617 linux(4): Deduplicate mprotect, madvise
MFC after:		1 week

(cherry picked from commit 553b1a4e4eb426d2c29a033b284c13bfbab30334)
2023-09-12 10:48:39 +03:00
Mitchell Horne
5adb91c729 pmc: better distinguish pmu-events allocation path
Background:

The pm_ev field of struct pmc_op_pmcallocate and struct pmc
traditionally contains the index of the chosen event, corresponding to
the __PMC_EVENTS array in pmc_events.h. This is a static list of events,
maintained by FreeBSD.

In the usual case, libpmc translates the user supplied event name
(string) into the pm_ev index, which is passed as an argument to the
allocation syscall. On the kernel side, the allocation method for the
relevant hwpmc class translates the given index into the event code that
will be written to an event selection register.

In 2018, a new source of performance event definitions was introduced:
the pmu-events json files, which are maintained by the Linux kernel. The
result was better coverage for newer Intel processors with a reduced
maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were
unconditionally switched to allocate events from pmu-events instead of
the traditional scheme (959826ca1b, 81eb4dcf9e).

Under the pmu-events scheme, the pm_ev field contains an index
corresponding to the selected event from the pmu-events table, something
which the kernel has no knowledge of. The configuration for the
performance counting registers is instead passed via class-dependent
fields (struct pmc_md_op_pmcallocate).

In 2021 I changed the allocation logic so that it would attempt to
pull from the pmu-events table first, and fall-back to the traditional
method (dfb4fb4116). Later, pmu-events support for arm64 and power8
CPUs was added (28dd6730a5 and b48a2770d4).

The problem that remains is that the pm_ev field is overloaded, without
a definitive way to determine whether the event allocation came from the
pmu-events table or FreeBSD's statically-defined PMC events. This
resulted in a recent fix, 21f7397a61.

Change:

To disambiguate these two supported but separate use-cases, add a new
flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that
the event index came from pmu-events.

This is useful in two ways:
 1. On the kernel side, we can validate the syscall arguments better.
    Some classes support only the traditional event scheme (e.g.
    hwpmc_armv7), while others support only the pmu-events method (e.g.
    hwpmc_core for Intel). We can now check for this. The hwpmc_arm64
    class supports both methods, so the new flag supersedes the existing
    MD flag, PM_MD_EVENT_RAW.

 2. The flag will be tracked in struct pmc for the duration of its
    lifetime, meaning it is communicated back to userspace. This allows
    libpmc to perform the reverse index-to-event-name translation
    without speculating about the meaning of the index value.

Adding the flag is a backwards-incompatible ABI change. We recently
bumped the major version of the hwpmc module, so this breakage is
acceptable.

Reviewed by:	jkoshy
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40753

(cherry picked from commit c190fb35f35cc163b61e582a49115680b0d49dcc)
2023-09-11 12:19:58 -07:00
Kyle Evans
8921130e3a arm64: initialize pcb in the TBI/PAC/etc. fault case
After 2c10be9e06, we may jump to the bad_far label without `pcb` being
set, resulting in a follow-up fault as we may dereference it immediately
after the jump if td_intr_nesting_level == 0.  In this branch, it should
be safe to dereference `td` as we're not handling the special case
mentioned below of accessing it during promotion/demotion.

This seems to fix a null ptr deref I hit during my most recent pkgbase
build attempt on the Windows DevKit, though that was admittedly
encountered while we were on the way to a panic from an apparent
use-after-free in ZFS bits.

Reviewed by:	andrew, markj
Approved by:	re (delphij)
Fixes:	2c10be9e06 ("arm64: Handle translation faults for thread [..]")

(cherry picked from commit 03d104888caea595960605a9ff010da7f39133dc)
2023-09-05 00:21:25 -05:00
Glen Barber
29a16ce065 release: update stable/14 following branching from main
Approved by:	re (implicit)
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd
2023-08-24 19:07:33 -04:00
Andrew Turner
7d2dd08d01 gicv3: Add checks for the device ID
Add checks that the device ID is supported by the hardware and is
within the range allocated when the driver attaches.

Reviewed by:	gallatin, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41554
2023-08-23 17:38:20 +01:00
Andrew Turner
629734783d gicv3: Add a verbose message for unknown tables
Add a message under bootverbose when we find a gicv3 its table type
that is unknown.

Reviewed by:	gallatin, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41553
2023-08-23 17:38:20 +01:00
Andrew Turner
2f11b2abfc gicv3: Stop setting the esize field
The GITS_BASER esize field is read-only, there is no need to change it.

Reviewed by:	gallatin, imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41552
2023-08-23 17:38:20 +01:00
Andrew Turner
43d74fcac0 Revert "gicv3: Stop setting the esize field"
This reverts commit 47a4b8ca96.

It has the wrong differential review link
2023-08-23 17:38:20 +01:00
Andrew Turner
b9cdb04f4e Revert "gicv3: Add a verbose message for unknown tables"
This reverts commit 7f9694ad7e.

It has the wrong differential review link
2023-08-23 17:38:20 +01:00
Andrew Turner
160919c864 Revert "gicv3: Add checks for the device ID"
This reverts commit 950421e231.

It has the wrong differential review link
2023-08-23 17:38:20 +01:00