Commit graph

3746 commits

Author SHA1 Message Date
Piotr Kubaj 83d6d8877e powerpc64*: port mlx5, OFED, KTLS and krping
Summary:
This review ports mlx5 driver, kernel's OFED stack (userland is already enabled), KTLS and krping to powerpc64 and powerpc64le.

krping requires a small change since it uses assembly for amd64 / i386.

NOTE: On powerpc64le RDMA works fine in the userspace with libmlx5, but on powerpc64 it does not. The problem is that contrib/ofed/libmlx5/doorbell.h checks for SIZEOF_LONG but this macro exists on neither powerpc64* nor amd64. Thus, the file silently goes to the fallback function written for 32-bit architectures. It works fine on little-endian architectures, but causes a hard fail on big-endian. It's possible it may also cause some runtime issues on little-endian.
Thus, on powerpc64 I verified that RDMA works with krping.

Reviewers: #powerpc, hselasky

Subscribers: bdrewery, imp, emaste, jhibbits

Differential Revision: https://reviews.freebsd.org/D38786
2023-02-26 00:56:37 +01:00
Mike Karels 8995b96f34 powerpc kernel config: clean up whitespace
Most options in kernel config files use "options<space><tab>OPTION".
This allows the option to be commented out without shifting columns.
A few options had two tabs, and some had spaces.  Make them consistent.
2023-02-24 08:36:29 -06:00
Mitchell Horne 6606096986 powerpc: remove nexus_get_cpus()
It is identical in functionality to root_get_cpus().

Reviewed by:	jhibbits
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38494
2023-02-16 17:29:22 -04:00
Warner Losh e35448a901 powerpc: Drop old workaround for old gcc
Very old versions of gcc defined _BIG_ENDIAN and _LITTLE_ENDIAN. So to
work around that, we undefined them here. However, that causes problems
for programs that do:

(and many other variations on that theme). Since this often is the
result of weirdly nested includes in the ports world that are hard to
unwind, drop this workaround to help more ports build out of the box.
If there's still an issue here (and my testing hasn't shown it), we'll
fix the issue in a brand-new way once I have a reproducer.

This fixes the mesa-devel build, and others

Sponsored by:		Netflix
Tested by:		pkubaj
MFC After:		3 days
Differential Revision:	https://reviews.freebsd.org/D38564
2023-02-14 09:47:08 -07:00
Mitchell Horne 53d5e65eea ofwbus: remove arm64 ifdefs
Rather than using the DEVICE_IDENTIFY method, let's have other
ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This
gives them the same flexibility, e.g. if riscv starts supporting ACPI,
and cleans up the #ifdefs.

We were doing this already on riscv, but adjust the 'order' parameters.

Reviewed by:	andrew, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D38492
2023-02-13 13:45:01 -04:00
Elliott Mitchell f9bdaab95e ofwbus: remove handling of resources from ofwbus
The architecture nexus should handle allocation and release of memory and
interrupts. This is to ensure that system-wide resources such as these
are available to all devices, not just children of ofwbus0.

On powerpc this moves the ownership of these resources up one level,
from ofwbus0 to nexus0. Other architectures already have the required
logic in their nexus implementation, so this eliminates the duplication
of resources. An implementation of nexus_adjust_resource() is added for
arm, arm64, and riscv.

As noted by ian@ in the review, resource handling was the main bit of
logic distinguishing ofwbus from simplebus. With some attention to
detail, it should be possible to merge the two in the future.

Co-authored by:	mhorne
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D30554
2023-02-08 16:50:46 -04:00
Val Packett 4a1c4de232 Allow sysctl hw.machine/hw.machine_arch in capability mode
There's no harm in reading strings like 'amd64'.

Reviewed by: emaste, manu
Sponsored by: https://www.patreon.com/valpackett
Differential Revision: https://reviews.freebsd.org/D28703
2023-02-06 14:00:52 -05:00
Konstantin Belousov 83a49712af kstack_contains(): account for struct pcb on stack
for arm64, arm, powerpc, and riscv

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38320
2023-02-02 00:59:27 +02:00
Konstantin Belousov 2555f175b3 Move kstack_contains() and GET_STACK_USAGE() to MD machine/stack.h
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38320
2023-02-02 00:59:26 +02:00
Justin Hibbits 3df047e3f3 Mechanically convert ps3 if_glc(4) to IfAPI
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37792
2023-01-31 16:26:35 -05:00
Alexander V. Chernikov e80699a809 netlink: add NETLINK to GENERIC.
This is a followup of 692e19cf51 (add netlink to GENERIC@amd64).

Netlink is a communication protocol defined in RFC 3549. It is async,
TLV-based protocol, providing 1-1 and 1-many communications between kernel
and userland. Netlink is currently used in Linux kernel to modify, read and
subscribe for nearly all networking states. Interface state, addresses, routes,
firewall, rules, fibs, etc, are controlled via Netlink.

Netlink support was added in D36002. It has got a number of improvements and
first customers since then:
* net/bird2 got netlink support, enabling route multipath in FreeBSD
* netlink-based devd notifications are being worked on ( D37574 ).
* linux(4) fully supports and depends on Netlink

Enabling Netlink in GENERIC targets two goals.
The first one is to provide stability for the third-party userland applications,
so they can rely on the fact that netlink always exists since 14.0 and potentially 13.2.
Loadable module makes life of the app delepers harder. For example, `net/bird2` can be
either build with netlink or rtsock support, but not both.

The second goal is to enable gradual conversion of the base userland tools
to use netlink(4) interfaces. Converting tools like netstat (D36529), route,
ifconfig one-by-one simplifies testing and addressing the feedback.
Othewise, switching all base to use netlink at once may be too big of a leap.

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D37783
2023-01-31 14:22:11 +00:00
Andrew Gallatin 9cb6ba29cb vm: centralize VM_BATCHQUEUE_SIZE definition
Remove the platform-specific definitions of VM_BATCHQUEUE_SIZE
for amd64 and powerpc64, and instead treat all 64-bit platforms
identically.  This has the effect of increasing the arm64
and riscv VM_BATCHQUEUE_SIZE to match that of other platforms.

Reviewed by: jhb, markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37707
2023-01-21 14:30:00 -05:00
Andrew Gallatin 1cac76c93f vm: reduce lock contention when processing vm batchqueues
Rather than waiting until the batchqueue is full to acquire the lock &
process the queue, we now start trying to acquire the lock using trylocks
when the batchqueue is 1/2 full. This removes almost all contention on the
vm pagequeue mutex for for our busy sendfile() based web workload.
It also greadly reduces the amount of time a network driver ithread
remains blocked on a mutex, and eliminates some packet drops under
heavy load.

So that the system does not loose the benefit of processing large
batchqueues, I've doubled the size of the batchqueues. This way, when
there is no contention, we process the same batch size as before.

This has been run for several months on a busy Netflix server, as well
as on my personal desktop.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37305
2022-12-14 14:34:07 -05:00
Justin Hibbits d1f3abc892 powerpc/mpc85xx: Add compat strings for P5040 PCIe
Submitted by:	widelec (widelec@morphos.pl)
MFC after:	1 week
2022-11-30 19:45:10 -05:00
Alfredo Dal'Ava Junior ff80ab1ceb powerpc: slb_alloc_user_cache: fix missing uma_zalloc wait flag
Flags should be M_WAITOK | M_ZERO instead of just M_ZERO

Reviewed by:	markj
MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D36865
2022-10-03 20:56:41 -03:00
John Baldwin f49fd63a6a kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.
Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36549
2022-09-22 15:09:19 -07:00
John Baldwin 7ae99f80b6 pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.
This matches the return type of pmap_mapdev/bios.

Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36548
2022-09-22 15:08:52 -07:00
Richard Scheffenegger bb1d472d79 tcp: make CUBIC the default congestion control mechanism.
This changes the default TCP Congestion Control (CC) to CUBIC.
For small, transactional exchanges (e.g. web objects <15kB), this
will not have a material effect. However, for long duration data
transfers, CUBIC allocates a slightly higher fraction of the
available bandwidth, when competing against NewReno CC.

Reviewed By: tuexen, mav, #transport, guest-ccui, emaste
Relnotes: Yes
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D36537
2022-09-13 12:09:21 +02:00
Gordon Bergling 01e7018587 powerpc: Correct some typos in source code comments
- s/occured/occurred/

MFC after:	3 days
2022-09-04 13:32:13 +02:00
John Baldwin e663907366 Define _NPCM and the last PC_FREEn constant in terms of _NPCPV.
This applies one of the changes from
5567d6b441 to other architectures
besides arm64.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36263
2022-08-23 13:31:02 -07:00
Dimitry Andric 02dd51c9bc Adjust function definitions in mp_cpudep.c.c to avoid clang 15 warnings
With clang 15, the following -Werror warnings are produced:

    sys/powerpc/booke/mp_cpudep.c:54:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cpudep_ap_bootstrap()
                       ^
                        void
    sys/powerpc/booke/mp_cpudep.c:97:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    cpudep_ap_setup()
                   ^
                    void

This is because cpudep_ap_bootstrap() and cpudep_ap_setup() are declared
with (void) argument lists, but defined with empty argument lists. Make
the definitions match the declarations.

MFC after:	3 days
2022-08-15 20:48:35 +02:00
Dimitry Andric ff490346fd Adjust function definition in moea64_native.c to avoid clang 15 warning
With clang 15, the following -Werror warning is produced:

    sys/powerpc/aim/moea64_native.c:306:22: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    moea64_install_native()
                         ^
                          void

This is because moea64_install_native() is declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after:	3 days
2022-08-15 20:48:35 +02:00
Dimitry Andric 3446738e8d Fix unused variable warning in mmu_radix.c
With clang 15, the following -Werror warning is produced:

    sys/powerpc/aim/mmu_radix.c:5409:22: error: variable 'freed' set but not used [-Werror,-Wunused-but-set-variable]
            int allfree, field, freed, idx;
                                ^

The 'freed' variable is only used when PV_STATS is defined. Ensure it is
only declared and set in that case.

MFC after:	3 days
2022-08-15 20:48:34 +02:00
Dimitry Andric fb203abd9d Adjust function definitions in mmu_radix.c to avoid clang 15 warnings
With clang 15, the following -Werror warnings are produced:

    sys/powerpc/aim/mmu_radix.c:786:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    mmu_radix_tlbie_all()
                       ^
                        void
    sys/powerpc/aim/mmu_radix.c:3615:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    mmu_radix_init()
                  ^
                   void
    sys/powerpc/aim/mmu_radix.c:6081:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    mmu_radix_scan_init()
                       ^
                        void

This is because mmu_radix_tlbie_all(), mmu_radix_init(), and
mmu_radix_scan_init() are declared with (void) argument lists, but
defined with empty argument lists. Make the definitions match the
declarations.

MFC after:	3 days
2022-08-15 20:48:34 +02:00
Dimitry Andric 7a98c884f2 Adjust function definitions in mmu_oea64.c to avoid clang 15 warnings
With clang 15, the following -Werror warnings are produced:

    sys/powerpc/aim/mmu_oea64.c:1947:12: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    moea64_init()
               ^
                void
    sys/powerpc/aim/mmu_oea64.c:3257:17: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    moea64_scan_init()
                    ^
                     void

This is because moea64_init() and moea64_scan_init() are declared with
(void) argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after:	3 days
2022-08-15 20:48:34 +02:00
Dimitry Andric 06fce030e7 Adjust function definition in aim_machdep.c to avoid clang 15 warning
With clang 15, the following -Werror warning is produced:

    sys/powerpc/aim/aim_machdep.c:750:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    mpc745x_sleep()
                 ^
                  void

This is because mpc745x_sleep() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after:	3 days
2022-08-15 20:48:34 +02:00
Justin Hibbits 35ce7d40f9 powerpc/booke: Clamp MAXCPU to 32 for Book-E platforms
Since the likelihood of new Book-E PowerPC SoCs being produced is near
zero clamp MAXCPU to around the highest number of cores/threads
available currently, for both 64-bit and 32-bit.  Even though the
current highest core/thread count is 24, the cap is set at 32 in case
there is code that assumes power of 2.
2022-08-06 11:42:19 -04:00
Justin Hibbits c0665d5c82 powerpc/fsl_sata: Properly clamp maxio to pessimized size
The CAM 'maxio' is a 'pessimized' size, assuming 4k pages and one page
per segment.  Since there are at most 63 segments in a transaction with
this driver, and one would necessarily be the indirect segment marker,
clamp the maxio to the minimum of maxphys (tunable) or (63 - 1) pages
(248k).

MFC after:	3 days
2022-08-04 21:32:03 -04:00
Alfredo Dal'Ava Junior 8b57548e9a powerpcspe: make GEOM_LABEL kernel built-in
Make powerpspe kernel config in sync with other targets making
GEOM_LABEL built-in to allow use of labels when mounting partitions.

MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
2022-08-02 18:17:09 -03:00
Konstantin Belousov c6d31b8306 AST: rework
Make most AST handlers dynamically registered.  This allows to have
subsystem-specific handler source located in the subsystem files,
instead of making subr_trap.c aware of it.  For instance, signal
delivery code on return to userspace is now moved to kern_sig.c.

Also, it allows to have some handlers designated as the cleanup (kclear)
type, which are called both at AST and on thread/process exit.  For
instance, ast(), exit1(), and NFS server no longer need to be aware
about UFS softdep processing.

The dynamic registration also allows third-party modules to register AST
handlers if needed.  There is one caveat with loadable modules: the
code does not make any effort to ensure that the module is not unloaded
before all threads processed through AST handler in it.  In fact, this
is already present behavior for hwpmc.ko and ufs.ko.  I do not think it
is worth the efforts and the runtime overhead to try to fix it.

Reviewed by:	markj
Tested by:	emaste (arm64), pho
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D35888
2022-08-02 21:11:09 +03:00
Justin Hibbits 43eebd0364 mpc85xx/pci: Conditionally reset PCI bridges
Sometimes we need to reset a PCIe bus, but sometimes it breaks the
downstream device(s).  Since, from my testing, this is only needed for
Radeon cards installed in the AmigaOne machines because the card was
already initialized by firmware, make the reset dependent on a device
hint (hint.pcib.X.reset=1).  With this, AmigaOne X5000 machines can have
other devices in the secondary PCIe slots.
2022-07-29 21:54:20 -04:00
John Baldwin ea8f128c7c pmap_mapdev: Consistently use vm_paddr_t for the first argument.
The devmap variants used vm_offset_t for some reason, and a few places
explicitly cast bus addresses to vm_offset_t.  (Probably those casts
along with similar casts for vm_size_t should just be removed and
instead permit the compiler to DTRT.)

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D35961
2022-07-28 15:55:10 -07:00
Kornel Dulęba 361971fbca Rework how shared page related data is stored
Store the shared page address in struct vmspace.
Also instead of storing absolute addresses of various shared page
segments save their offsets with respect to the shared page address.
This will be more useful when the shared page address is randomized.

Approved by:	mw(mentor)
Sponsored by:	Stormshield
Obtained from:	Semihalf
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D35393
2022-07-18 16:27:32 +02:00
Kornel Dulęba f6ac79fb12 Introduce the PROC_SIGCODE() macro
Use a getter macro instead of fetching the sigcode address directly
from a sysent of a given process. It assumes that the sigcode is stored
in the shared page, which is true in all cases, except for a.out
binaries. This will be later useful when the shared page address
randomization is introduced.
No functional change intended.

Approved by:	mw(mentor)
Sponsored by:	Stormshield
Obtained from:	Semihalf
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D35392
2022-07-18 16:27:26 +02:00
Mark Johnston ece453d5fa eventtimer: Simplify KTR traces
Stop including the current CPU in all event messages, since it's already
saved in KTR log entries and thus is redundant.  All eventtimer traces
occur in a context where CPU migration is not possible.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-07-11 15:58:43 -04:00
Mitchell Horne 29afffb942 subr_bus: restore bus_null_rescan()
Partially revert the previous change; we need to keep this method as a
specific override for pci_driver subclasses which should not use
pci_rescan_method() -- cardbus and ofw_pcibus. However, change the return
value to ENODEV for the same reasoning given in the original commit, and
use this as the default rescan method in bus_if.m.

Reported by:	jhb
Fixes:		36a8572ee8 ("bus_if: provide a default null rescan method")
MFC with:	36a8572ee8
2022-06-23 16:07:00 -03:00
Mitchell Horne 8701571df9 set_cputicker: use a bool
The third argument to this function indicates whether the supplied
ticker is fixed or variable, i.e. requiring calibration. Give this
argument a type and name that better conveys this purpose.

Reviewed by:	kib, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35459
2022-06-23 15:15:11 -03:00
Mitchell Horne 36a8572ee8 bus_if: provide a default null rescan method
There is an existing helper method in subr_bus.c, but almost no drivers
know to use it. It also returns the same error as an empty method,
making it not very useful. Move this to bus_if.m and return a more
sensible error code.

This gives a slightly more meaningful error message when attempting
'devctl rescan' on buses and devices alike:
  "Device not configured" --> "Operation not supported by device"

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35501
2022-06-23 15:15:10 -03:00
Gordon Bergling 23615a3e4e powerpc: Fix a typo in a comment
- s/layed/laid/

MFC after:	3 days
2022-06-04 19:55:03 +02:00
Gordon Bergling d8dd4b2fd2 powerpc: Fix two typos in source code comments
- s/auxillary/auxiliary/

MFC after:	3 days
2022-06-04 10:39:50 +02:00
Dmitry Chagin eca368ecb6 Retire sv_transtrap
Call translate_traps directly from sendsig().

MFC after:		2 weeks
2022-05-20 14:54:03 +03:00
Mitchell Horne db71383b88 kerneldump: remove physical from dump routines
It is unused, especially now that the underlying d_dumper methods do not
accept the argument.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35174
2022-05-13 10:43:19 -03:00
John Baldwin 0a763c165f powerpc nexus: Remove unused devclass argument to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin f92448c993 powerpc psim: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 9b9a532782 powerpc pseries: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin c331b0e4a3 powerpc ps3: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 5edf159ff1 powerpc powernv: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 992ae60ba4 powerpc powermac: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 5d7d6129f4 powerpc mpc85xx: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 54b3d1efbf rbled: Remove unused devclass argument to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin f6a99df5da powerpc mambo: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin b9f8eda4eb powerpc amigaone: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-10 10:21:38 -07:00
John Baldwin 52ed569ba5 Remove unused openpic_devclass. 2022-05-10 10:21:38 -07:00
John Baldwin 42f777fc20 Remove unused adb_devclass. 2022-05-10 10:21:38 -07:00
John Baldwin 03f6459cb3 ofw drivers: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 14:26:44 -07:00
John Baldwin c90ea83112 Remove unused uart_devclass. 2022-05-06 15:46:57 -07:00
John Baldwin 676ea8e177 Remove unused iicbus_devclass. 2022-05-06 15:39:30 -07:00
John Baldwin b3407dcc58 cpufreq: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:39:29 -07:00
John Baldwin d5a7306c75 ata: Remove ata_devclass from DRIVER_MODULE invocations.
Keep the global variable for its uses in ata-pci.c and
chipsets/ata-fsl.c but initialize it in the existing
ata_module_event_handler.  Move the module event handler a bit earlier
to ensure the variable is set before any devices are attached.
2022-05-06 15:36:10 -07:00
Piotr Kubaj 25768526bb powerpc: enable wlan and ath modules in GENERIC64*
Reviewed by:	jhibbits (src)
Differential Revision: https://reviews.freebsd.org/D35089
2022-04-28 11:42:39 +02:00
John Baldwin e4a38f5407 powerpc pseries xics: Use devclass_find to lookup xicp devclass.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D35083
2022-04-27 15:08:47 -07:00
Dmitry Chagin fe2c9f83a6 Remove dead code.
is_physical_memory() dead since 235a54de.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35056
MFC after:		2 weeks
2022-04-26 19:40:59 +03:00
Piotr Kubaj 1d307cc85c powerpc: add GENERIC64LE-NODEBUG config and improve GENERIC64-NODEBUG
Also remove whitespace from GENERIC-NODEBUG.

Approved by: jhibbits (src)
Differential review:	https://reviews.freebsd.org/D34785
2022-04-22 01:06:13 +02:00
John Baldwin d4ab3a8d4f busdma_bounce: Add free_bounce_pages helper function.
Deduplicate code to iterate over the bpages list in a bus_dmamap_t
freeing bounce pages during bus_dmamap_unload.

Reviewed by:	imp
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D34967
2022-04-21 10:42:14 -07:00
Brooks Davis c2f6aae007 machine/in_cksum.h: don't include sys/cdefs.h
All consumers already do it and it was required on amd64 and i386
until recently (1c1bf5bd7c).

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34932
2022-04-18 21:02:19 +01:00
John Baldwin 7c1ff7146b powerpc cpu_idle_60x: Move some variables fully under #ifdef AIM.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34905
2022-04-18 12:08:35 -07:00
John Baldwin ff1de4e02e powerpc booke cpu_machine_check: Remove unused variable.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34902
2022-04-18 12:08:10 -07:00
John Baldwin 6f568b14cb powerpc cpu_idle_booke: Move read of mfmsr under #ifdef BOOKE_E500.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34891
2022-04-18 12:07:34 -07:00
John Baldwin d5472cd4b3 ata_kauai: Fix support for "shasta" controllers.
The probe routine was setting a value in the softc, but since the
probe routine was not returning zero, this value was lost since the
softc was reallocated (and re-zeroed) when the device was attached.
This is similar in nature to the fixes from
965205eb66.

To fix, move the code to set the 'shasta' flag to the start of attach
along with related code to set an IRQ resource on some non-shasta
devices.  The IRQ resource still "worked" being in the probe routine
as the IRQ resource persisted after probe returned, but it is cleaner
to go ahead and move it to attach after setting the 'shasta' flag.

I have no way to test this, but noticed this while reading the code.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34888
2022-04-18 12:06:52 -07:00
John Baldwin a30eb84a5d powerpc mpc85xx: Remove unused variables. 2022-04-13 16:08:24 -07:00
John Baldwin 1c311640c0 powerpc: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:23 -07:00
John Baldwin f602f7e6f7 opalflash: Remove unused variable. 2022-04-12 14:58:59 -07:00
John Baldwin 01d643ae93 ps3fb: Remove unused variable. 2022-04-12 14:58:59 -07:00
John Baldwin b2a8b342f3 llan: Remove unused variables.
In theory the errors during llan_attach should be handled, but other
errors in llan_attach (e.g. bus_setup_intr) are already ignored, so
just remove the unused variable to preserve the status quo.
2022-04-12 14:58:59 -07:00
John Baldwin 7e7f7b91d0 powerpc cpudep_ap_setup: Quite unused variable warnings. 2022-04-12 14:58:59 -07:00
John Baldwin da8b238529 powerpc: Remove unused variables. 2022-04-12 14:58:58 -07:00
John Baldwin b7fe00faea powerpc pmu: Quiet set but unused warnings.
- Remove unused variables.

- Replace a dummy variable with a void cast.
2022-04-12 14:58:58 -07:00
John Baldwin 5f2995aa95 powerpc pmu: Don't use garbage battery info.
If pmu_query_battery fails, don't notify a change in battery status.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D34889
2022-04-12 14:58:58 -07:00
John Baldwin 2ad93a4f6b grackle badaddr: Use void casts instead of a dummy variable. 2022-04-12 14:58:58 -07:00
John Baldwin 9c861e931c cuda: Remove unused variables. 2022-04-12 14:58:58 -07:00
John Baldwin 6e31d66849 ata_dbdma_dmainit: Remove unused variable. 2022-04-12 14:58:58 -07:00
John Baldwin 019493db3e ata_kauai: Remove unused variable. 2022-04-12 14:58:58 -07:00
John Baldwin 6d0f9c91cb powerpc cpufreq: Remove unused variables. 2022-04-12 14:58:58 -07:00
John Baldwin c9d26ca24c ppc mmoea64: Workaround set but unused warnings for RB_NEXT.
Inline the unused expression passed as the second argument to RB_NEXT.
2022-04-12 14:58:58 -07:00
John Baldwin 8d95af873f ppc aim flush_disable_caches: Use void casts instead of a dummy variable. 2022-04-12 14:58:58 -07:00
John Baldwin 3d6f4411e4 Remove checks for <sys/cdefs.h> being included.
These files no longer depend on the macros required when these checks
were added.

PR:		263102 (exp-run)
Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34804
2022-04-12 10:06:18 -07:00
John Baldwin 5f9c9ae2f2 Remove checks for __CC_SUPPORTS_WARNING assuming it is always true.
All supported compilers (modern versions of GCC and clang) support
this.

PR:		263102 (exp-run)
Reviewed by:	brooks, imp
Differential Revision:	https://reviews.freebsd.org/D34803
2022-04-12 10:06:13 -07:00
Gordon Bergling f259d24fa5 powerpc: Fix two typos in source code comments
- s/mutiplying/multiplying/

MFC after:	3 days
2022-04-09 09:14:07 +02:00
Alfredo Dal'Ava Junior 27f56d337b powerpcspe: fix PCI enumeration on ppce500
This fixes PCI devices not being found on QEMU ppce500. This
generic board used to have its first PCI slot at 0x11, like the
mpc8544dsi and some real HW. After commit [1], it was changed to
0x1 and our driver wasn't prepared for that.

[1] 3bb7e02a97

Reviewed by:	jhibbits, bdragon
MFC after:	2 days
Sponsored by:	Institudo de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D34621
2022-03-21 16:11:33 -03:00
Alfredo Dal'Ava Junior aa37fbc200 powerpcspe: add virtio in-kernel support
Adding it in order to make easier using powerpcspe images under qemu

Reviewed by:	jhibbits
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D34554
2022-03-15 09:34:22 -03:00
Alfredo Dal'Ava Junior c3b6408ee8 powerpc: FreeBSD kernel compatibility cleanup
Adjust FreeBSD kernel backward compatibility list

Reviewed by:	jhibbits, pkubaj
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33421
2022-03-07 14:30:26 -03:00
Mateusz Guzik b53133a778 proc: load/store p_cowgen using atomic primitives 2022-02-13 13:07:08 +00:00
Warner Losh 6e48e160ae powerpc: Add static asssert for context size
Add a static assert for the siginfo_t, mcontext_t and ucontext_t
sizes. These are de-facto ABI options and cannot change size ever. For
powerpc64, also add asserts for {u,m}mcontext32_t and siginfo32.

Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D34213
2022-02-10 14:32:20 -07:00
John Baldwin c227269e2f Stop adding -Wredundant-decls to CWARNFLAGS.
clang doesn't implement it, and Linux doesn't enforce it.  As a
result, new instances keep cropping up both in FreeBSD's code and in
upstream sources from vendors.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34144
2022-02-07 12:47:51 -08:00
Justin Hibbits aa4736459e powerpc/atomic: Fix atomic_testand_*_long on powerpc64
After b5d227b0 FreeBSD was panicking on boot with "Duplicate free" in
UMA.  Analyzing the asm, the '1' mask was treated as an integer, rather
than a long, causing 'slw' (shift left word) to be used for the shifting
instruction, not 'sld' (shift left double).  This means the upper bits
of the bitfield were not getting used, resulting in corruption of the
bitfield.

While fixing this, the 'and' check of the mask does not need to be
recorded, so don't record (drop the '.').
2022-02-03 17:25:39 -06:00
Andrew Turner 548a2ec49b Add PT_GETREGSET
This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19831
2022-01-27 11:40:34 +00:00
Piotr Kubaj a0f3abb098 powerpc: enable ice in GENERIC64LE
Approved by:	erj
Differential Revision: https://reviews.freebsd.org/D33974
2022-01-21 02:17:46 +01:00
Mark Johnston 3fc21fdd5f sysent: Add a sv_psstringssz field to struct sysentvec
The size of the ps_strings structure varies between ABIs, so this is
useful for computing the address of the ps_strings structure relative to
the top of the stack when stack address randomization is enabled.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 11:42:07 -05:00
Li-Wen Hsu 62b4e25f05
powerpc: Fix syntax atomic.h
Fixes:	b5d227b0b2 powerpc: Add atomic_testand_{set,clear}_{int,long}
2022-01-14 19:11:22 +08:00
Justin Hibbits 4873653519 powerpc64le: enable ISA_206_ATOMICS option
powerpc64le requires at minimum POWER8 hardware, so ISA 2.06 atomic
instructions are always available.

This isn't so for powerpc64 (BE), so isn't enabled by default there.
2022-01-13 21:47:05 -06:00
Justin Hibbits b5d227b0b2 powerpc: Add atomic_testand_{set,clear}_{int,long}
Add machine-optimized implementations for the following:
* atomic_testandset_int
* atomic_testandclear_int
* atomic_testandset_long
* atomic_testandclear_long

This fixes the build with ISA_206_ATOMICS enabled.
Add the associated atomic_testandset_32, atomic_testandclear_32, so
that ice(4) can potentially build.
2022-01-13 21:46:52 -06:00
Warner Losh 47796d47ec powerpc/aim: ifdef DDB pmap debugging functions
INVARIANTS and DDB can be enabled independently.

Submitted by: Sterling Jensen
Pull Request: https://github.com/freebsd/freebsd-src/pull/566
2022-01-07 08:56:57 -07:00
John Baldwin 7def1e10b3 bus_dma: Deduplicate locking helper functions.
- Move busdma_lock_mutex to subr_bus_dma.c.

- Move _busdma_lock_dflt to subr_bus_dma.c.  This function was named a
  couple of different things previously.  It is not a public API but
  an internal helper used in place of a NULL pointer.  The prototype
  is in <sys/bus_dma.h> as not all backends include
  <sys/bus_dma_internal.h>.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33694
2022-01-05 13:50:40 -08:00
John Baldwin 85b4607324 Deduplicate bus_dma bounce code.
Move mostly duplicated code in various MD bus_dma backends to support
bounce pages into sys/kern/subr_busdma_bounce.c.  This file is
currently #include'd into the backends rather than compiled standalone
since it requires access to internal members of opaque bus_dma
structures such as bus_dmamap_t and bus_dma_tag_t.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33684
2022-01-05 13:50:40 -08:00
Justin Hibbits 3a9688f8bc busdma: Fix powerpc DMA alignment check
The original logic was to check if there's no filter and the address is
misaligned relative to the requirements.  The refactoring in
c606ab59e7 missed this, and instead caused
it to return failure if the address *is* properly aligned.
2022-01-04 09:24:03 -06:00
Doug Moore f1e7a532d1 busdma: _bus_dmamap_addseg repaired
A recent change introduced a one-off error into a test allowing
coalescing chunks into segments.  This fixes that error.

broke a check in _bus_dmamap_addseg on many architectures. This change makes it clear that it is not a particular range that is being boundary-checked, but the proposed union of the two adjacent ranges.
Reported by:	se
Reviewed by:	se
Fixes:	c606ab59e7 vm_extern: use standard address checkers everywhere
Differential Revision:	https://reviews.freebsd.org/D33715
2022-01-02 12:37:05 -06:00
Doug Moore c606ab59e7 vm_extern: use standard address checkers everywhere
Define simple functions for alignment and boundary checks and use them
everywhere instead of having slightly different implementations
scattered about. Define them in vm_extern.h and use them where
possible where vm_extern.h is included.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D33685
2021-12-30 22:09:08 -06:00
Stefan Eßer e2650af157 Make CPU_SET macros compliant with other implementations
The introduction of <sched.h> improved compatibility with some 3rd
party software, but caused the configure scripts of some ports to
assume that they were run in a GLIBC compatible environment.

Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being
added to ports, but there still were compatibility issues due to
invalid assumptions made in autoconfigure scripts.

The differences between the FreeBSD version of macros like CPU_AND,
CPU_OR, etc. and the GLIBC versions was in the number of arguments:
FreeBSD used a 2-address scheme (one source argument is also used as
the destination of the operation), while GLIBC uses a 3-adderess
scheme (2 source operands and a separately passed destination).

The GLIBC scheme provides a super-set of the functionality of the
FreeBSD macros, since it does not prevent passing the same variable
as source and destination arguments. In code that wanted to preserve
both source arguments, the FreeBSD macros required a temporary copy of
one of the source arguments.

This patch set allows to unconditionally provide functions and macros
expected by 3rd party software written for GLIBC based systems, but
breaks builds of externally maintained sources that use any of the
following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR.

One contributed driver (contrib/ofed/libmlx5) has been patched to
support both the old and the new CPU_OR signatures. If this commit
is merged to -STABLE, the version test will have to be extended to
cover more ranges.

Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do
no longer require that option.

The FreeBSD version has been bumped to 1400046 to reflect this
incompatible change.

Reviewed by:	kib
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33451
2021-12-30 12:20:32 +01:00
John Baldwin 254e4e5b77 Simplify swi for bus_dma.
When a DMA request using bounce pages completes, a swi is triggered to
schedule pending DMA requests using the just-freed bounce pages.  For
a long time this bus_dma swi has been tied to a "virtual memory" swi
(swi_vm).  However, all of the swi_vm implementations are the same and
consist of checking a flag (busdma_swi_pending) which is always true
and if set calling busdma_swi.  I suspect this dates back to the
pre-SMPng days and that the intention was for swi_vm to serve as a
mux.  However, in the current scheme there's no need for the mux.

Instead, remove swi_vm and vm_ih.  Each bus_dma implementation that
uses bounce pages is responsible for creating its own swi (busdma_ih)
which it now schedules directly.  This swi invokes busdma_swi directly
removing the need for busdma_swi_pending.

One consequence is that the swi now works on RISC-V which had previously
failed to invoke busdma_swi from swi_vm.

Reviewed by:	imp, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33447
2021-12-28 13:51:25 -08:00
Brandon Bergren c583b02587 [PowerPC] PowerMac timebase sync for G4
Summary:
Disable timebase on (some) AIM platforms (tested on PowerMac G4) prior
to synchronization.

Some platforms use a GPIO to enable and disable timebase, while others
use a platform function.

This mirrors 0d69f00b on mpc85xx.

Todo:
 * Implement various G5 timebase controls.
 * Print out platform code on unknown G5s so we can collect it.
 * Change API to be give/take pairs like Linux does so it's possible to
   do a software sync protocol.

Reviewed By: #powerpc, jhibbits
Subscribers: mikael, markmi_dsl-only.net, luporl, alfredo
Tags: #powerpc
Differential Revision: https://reviews.freebsd.org/D29136
2021-12-23 16:06:07 -06:00
Hans Petter Selasky eb771bf6f4 Implement suword16() for 32-bit and 64-bit PowerPC architecture.
This fixes compilation of usb(4) after 0ec590d24e .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-19 13:17:55 +01:00
Hans Petter Selasky e98efdd973 Implement suword16() for the 32/64-bit PowerPC architecture.
This fixes compilation of usb(4) after 0ec590d24e .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-19 12:21:21 +01:00
Leandro Lupori a076e2060c powerpc64: fix the calculation of Maxmem
The calculation of Maxmem was skipping the last phys_avail segment,
because of a wrong stop condition.

This was detected when using QEMU/PowerNV with Radix MMU and low
memory (2G). In this case opal_pci would allocate a DMA window that
was too small to cover all physical memory, resulting in reading all
zeroes from disk when using memory that was not inside the allocated
window.

Reviewed by:		jhibbits
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33449
MFC after:		2 weeks
2021-12-15 08:49:47 -03:00
Alfredo Dal'Ava Junior 8d1ab5ad84 powerpc: kernel config style
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Reviewed by:	imp
2021-12-14 21:01:25 -03:00
Alexander Motin 8493918868 busdma: Remove outdated comments about Giant.
MFC after:	2 weeks
2021-12-09 22:18:53 -05:00
John Baldwin 1a62e9bc00 Add <machine/tls.h> header to hold MD constants and helpers for TLS.
The header exports the following:

- Definition of struct tcb.
- Helpers to get/set the tcb for the current thread.
- TLS_TCB_SIZE (size of TCB)
- TLS_TCB_ALIGN (alignment of TCB)
- TLS_VARIANT_I or TLS_VARIANT_II
- TLS_DTV_OFFSET (bias of pointers in dtv[])
- TLS_TP_OFFSET (bias of "thread pointer" relative to TCB)

Note that TLS_TP_OFFSET does not account for if the unbiased thread
pointer points to the start of the TCB (arm and x86) or the end of the
TCB (MIPS, PowerPC, and RISC-V).

Note also that for amd64, the struct tcb does not include the unused
tcb_spare field included in the current structure in libthr.  libthr
does not use this field, and the existing calls in libc and rtld that
allocate a TCB for amd64 assume it is the size of 3 Elf_Addr's (and
thus do not allocate room for tcb_spare).

A <sys/_tls_variant_i.h> header is used by architectures using
Variant I TLS which uses a common struct tcb.

Reviewed by:	kib (older version of x86/tls.h), jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33351
2021-12-09 13:17:13 -08:00
Brooks Davis 547566526f Make struct syscall_args machine independent
After a round of cleanups in late 2020, all definitions are
functionally identical.

This removes a rotted __aligned(8) on arm. It was added in
b7112ead32 and was intended to align the
args member so that 64-bit types (off_t, etc) could be safely read on
armeb compiled with clang. With the removal of armev, this is no
longer needed (armv7 requires that 32-bit aligned reads of 64-bit
values be supported and we enable such support on armv6).  As further
evidence this is unnecessary, cleanups to struct syscall_args have
resulted in args being 32-bit aligned on 32-bit systems.  The sole
effect is to bloat the struct by 4 bytes.

Reviewed by:	kib, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D33308
2021-12-08 18:45:33 +00:00
Mitchell Horne b02908b051 arm64, powerpc: fix calculation of 'used' in GET_STACK_USAGE
We do not consider the space reserved for the pcb to be part of the
total kstack size, so it should not be included in the calculation of
the used stack size.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-30 11:15:44 -04:00
Alfredo Dal'Ava Junior e671037b3c powerpc64le: add LINT64LE kernel config
Add configuration file to be used by "FreeBSD-<branch>-powerpc64le-LINT"
CI/Jenkins job

Reviewed by:	lwhsu
MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33136
2021-11-29 12:08:26 -03:00
Leandro Lupori e141b62d20 powerpc64le: fix boot when using QEMU PowerNV
When using QEMU PowerNV with latest op-build release (v2.7), its
kexec transfers control to FreeBSD kernel in BE mode, causing an
instant exception on LE kernels. Make kboot able to detect and
swap endian to fix this.

Reviewed by:		imp
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33104
2021-11-25 16:41:46 -03:00
Leandro Lupori b9f3b63ab2 vt: export RGB offsets with FBIO_GETRGBOFFS
Add a new ioctl to vt to make it possible to export RGB offsets
set by vt drivers. This is needed to fix colors on X and Mesa
on some machines, especially on modern PowerPC64 BE ones.

With the appropriate changes in SCFB, to use this ioctl to find
out the correct RGB offsets, this fixes wrong colors on Talos II
and Blackbird, when used with their built-in video cards.

Reviewed by:		alfredo
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D29000
2021-11-25 16:39:25 -03:00
Mark Johnston ecbbe83144 netinet: Deduplicate most in_cksum() implementations
in_cksum() and related routines are implemented separately for each
platform, but only i386 and arm have optimized versions.  Other
platforms' copies of in_cksum.c are identical except for style
differences and support for big-endian CPUs.

Deduplicate the implementations for the rest of the platforms.  This
will make it easier to implement in_cksum() for unmapped mbufs.  On arm
and i386, define HAVE_MD_IN_CKSUM to mean that the MI implementation is
not to be compiled.

No functional change intended.

Reviewed by:	kp, glebius
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33095
2021-11-24 13:31:16 -05:00
Mark Johnston 09100f936b netinet: Remove in_cksum_update()
It was never implemented on powerpc or riscv and appears to have been
unused since it was added in 1998.  No functional change intended.

Reviewed by:	kp, glebius, cy
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33093
2021-11-24 13:31:15 -05:00
Warner Losh 76d6bb6a6e powerpc: Make machine/reg.h self-contained
Make powerpc*'s machine/reg.h self-contained so that sys/reg.h can be
self-contained.

Sponsored by:		Netflix
2021-11-23 21:21:18 -07:00
Mitchell Horne 10fe6f80a6 minidump: Use the provided dump bitset
When constructing the set of dumpable pages, use the bitset provided by
the state argument, rather than assuming vm_page_dump invariably. For
normal kernel minidumps this will be a pointer to vm_page_dump, but when
dumping the live system it will not.

To do this, the functions in vm_dumpset.h are extended to accept the
desired bitset as an argument. Note that this provided bitset is assumed
to be derived from vm_page_dump, and therefore has the same size.

Reviewed by:	kib, markj, jhb
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31992
2021-11-19 15:05:52 -04:00
Mitchell Horne 1d2d1418b4 minidump: Use provided msgbuf pointer
Don't assume we are dumping the global message buffer, but use the one
provided by the state argument. While here, drop superfluous
cast to char *.

Reviewed by:	markj, jhb
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31991
2021-11-19 15:05:52 -04:00
Mitchell Horne 1adebe3cd6 minidump: Parameterize minidumpsys()
The minidump code is written assuming that certain global state will not
change, and rightly so, since it executes from a kernel debugger
context. In order to support taking minidumps of a live system, we
should allow copies of relevant global state that is likely to change to
be passed as parameters to the minidumpsys() function.

This patch does the work of parameterizing this function, by adding a
struct minidumpstate argument. For now, this struct allows for copies of
the kernel message buffer, and the bitset that tracks which pages should
be dumped (vm_page_dump). Follow-up changes will actually make use of
these arguments.

Notably, dump_avail[] does not need a snapshot, since it is not expected
to change after system initialization.

The existing minidumpsys() definitions are renamed, and a thin MI
wrapper is added to kern_dump.c, which handles the construction of
the state struct. Thus, calling minidumpsys() remains as simple as
before.

Reviewed by:	kib, markj, jhb
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D31989
2021-11-19 15:05:52 -04:00
Kristof Provost 4e85b64890 Add a COMPAT_FREEBSD13 kernel option
Use it wherever COMPAT_FREEBSD11 is currently specified.

Reviewed by:	jhb (previous version)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33005
2021-11-17 03:08:40 +01:00
Warner Losh 7e3c9ec906 tcp: better congestion control defaults
Define CC_NEWRENO in all the appropriate DEFAULTS and std.* config
files. It's the default congestion control algorithm.  Add code to cc.c
so that CC_DEFAULT is "newreno" if it's not overriden in the config
file.

Sponsored by: Netflix
Fixes: b8d60729de ("tcp: Congestion control cleanup.")
Revired by: manu, hselasky, jhb, glebius, tuexen
Differential Revision:	https://reviews.freebsd.org/D32964
2021-11-12 12:16:11 -07:00
Randall Stewart b8d60729de tcp: Congestion control cleanup.
NOTE: HEADS UP read the note below if your kernel config is not including GENERIC!!

This patch does a bit of cleanup on TCP congestion control modules. There were some rather
interesting surprises that one could get i.e. where you use a socket option to change
from one CC (say cc_cubic) to another CC (say cc_vegas) and you could in theory get
a memory failure and end up on cc_newreno. This is not what one would expect. The
new code fixes this by requiring a cc_data_sz() function so we can malloc with M_WAITOK
and pass in to the init function preallocated memory. The CC init is expected in this
case *not* to fail but if it does and a module does break the
"no fail with memory given" contract we do fall back to the CC that was in place at the time.

This also fixes up a set of common newreno utilities that can be shared amongst other
CC modules instead of the other CC modules reaching into newreno and executing
what they think is a "common and understood" function. Lets put these functions in
cc.c and that way we have a common place that is easily findable by future developers or
bug fixers. This also allows newreno to evolve and grow support for its features i.e. ABE
and HYSTART++ without having to dance through hoops for other CC modules, instead
both newreno and the other modules just call into the common functions if they desire
that behavior or roll there own if that makes more sense.

Note: This commit changes the kernel configuration!! If you are not using GENERIC in
some form you must add a CC module option (one of CC_NEWRENO, CC_VEGAS, CC_CUBIC,
CC_CDG, CC_CHD, CC_DCTCP, CC_HTCP, CC_HD). You can have more than one defined
as well if you desire. Note that if you create a kernel configuration that does not
define a congestion control module and includes INET or INET6 the kernel compile will
break. Also you need to define a default, generic adds 'options CC_DEFAULT=\"newreno\"
but you can specify any string that represents the name of the CC module (same names
that show up in the CC module list under net.inet.tcp.cc). If you fail to add the
options CC_DEFAULT in your kernel configuration the kernel build will also break.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
RELNOTES:YES
Differential Revision: https://reviews.freebsd.org/D32693
2021-11-11 06:28:18 -05:00
Kyle Evans 6a8ea6d174 sched: split sched_ap_entry() out of sched_throw()
sched_throw() can no longer take a NULL thread, APs enter through
sched_ap_entry() instead.  This completely removes branching in the
common case and cleans up both paths.  No functional change intended.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D32829
2021-11-05 15:45:51 -05:00
Kyle Evans 589aed00e3 sched: separate out schedinit_ap()
schedinit_ap() sets up an AP for a later call to sched_throw(NULL).

Currently, ULE sets up some pcpu bits and fixes the idlethread lock with
a call to sched_throw(NULL); this results in a window where curthread is
setup in platforms' init_secondary(), but it has the wrong td_lock.
Typical platform AP startup procedure looks something like:

- Setup curthread
- ... other stuff, including cpu_initclocks_ap()
- Signal smp_started
- sched_throw(NULL) to enter the scheduler

cpu_initclocks_ap() may have callouts to process (e.g., nvme) and
attempt to sched_add() for this AP, but this attempt fails because
of the noted violated assumption leading to locking heartburn in
sched_setpreempt().

Interrupts are still disabled until cpu_throw() so we're not really at
risk of being preempted -- just let the scheduler in on it a little
earlier as part of setting up curthread.

Reviewed by:	alfredo, kib, markj
Triage help from:	andrew, markj
Smoke-tested by:	alfredo (ppc), kevans (arm64, x86), mhorne (arm)
Differential Revision:	https://reviews.freebsd.org/D32797
2021-11-03 15:54:59 -05:00
Mark Johnston ff93447d8e Use the vm_radix_init() helper when initializing pmaps
No functional change intended.

Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32527
2021-10-19 21:22:56 -04:00
Mark Johnston 84c3922243 Convert consumers to vm_page_alloc_noobj_contig()
Remove now-unneeded page zeroing.  No functional change intended.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32006
2021-10-19 21:22:56 -04:00
Mark Johnston a4667e09e6 Convert vm_page_alloc() callers to use vm_page_alloc_noobj().
Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ.  In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.

Similarly, convert vm_page_alloc_domain() callers.

Note that callers are now responsible for assigning the pindex.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31986
2021-10-19 21:22:56 -04:00
Leandro Lupori 8ecf9a8bab powerpc64: make radix with superpages default
As Radix MMU with superpages enabled is now stable, make it the
default choice on supported hardware (POWER9 and above), since its
performance is greater than that of HPT MMU.

Reviewed by:		alfredo, jhibbits
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D30797
2021-10-14 13:13:27 -03:00
Leandro Lupori 76384bd10f powerpc64: fix OFWFB with Radix MMU
Current implementation of Radix MMU doesn't support mapping
arbitrary virtual addresses, such as the ones generated by
"direct mapping" I/O addresses. This caused the system to hang, when
early I/O addresses, such as those used by OpenFirmware Frame Buffer,
were remapped after the MMU was up.

To avoid having to modify mmu_radix_kenter_attr just to support this
use case, this change makes early I/O map use virtual addresses from
KVA area instead (similar to what mmu_radix_mapdev_attr does), as
these can be safely remapped later.

Reviewed by:		alfredo (earlier version), jhibbits (in irc)
MFC after:		2 weeks
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31232
2021-10-14 10:39:52 -03:00
Konstantin Belousov 4cc167a352 Restore PPS_SYNC in NOTES
This partially reverts e81e77c5a0, leaving the option both in
GENERICs on amd64/arm64/arm, and in global NOTES file.  Apparently
this better matches existing practice, where we do not try to hard
to make LINT and GENERIC complimentary.

Requested and reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-10-12 23:10:35 +03:00
Konstantin Belousov e81e77c5a0 Enable PPS_SYNC on amd64, arm64 and armv7
Remove the option from NOTES/LINT, and add to NOTES for powerpc and
riscv.

PR:	259036
Requested by:	John Hay <john@sanren.ac.za>
Discussed with:	ian, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-10-10 22:34:40 +03:00
Mitchell Horne ab4ed843a3 minidump: De-duplicate the progress bar
The implementation of the progress bar is simple, but duplicated for
most minidump implementations. Extract the common bits to kern_dump.c.
Ensure that the bar is reset with each subsequent dump; this was only
done on some platforms previously.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31885
2021-09-29 16:42:21 -03:00
Mitchell Horne 31991a5a45 minidump: De-duplicate is_dumpable()
The function is identical in each minidump implementation, so move it to
vm_phys.c. The only slight exception is powerpc where the function was
public, for use in moea64_scan_pmap().

Reviewed by:	kib, markj, imp (earlier version)
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31884
2021-09-29 16:41:52 -03:00
Leandro Lupori 4f7c436548 powerpc64: fix radix on pseries TLB invalidation
When running in a virtualized environment, TLB invalidations can only
be performed on process scope, as only the hypervisor is allowed to
invalidate a global scope, or else a Program Interrupt is triggered.

Since we are here, also make sure that the register process table
hypercall returns success.

Reviewed by:		jhibbits
MFC after:		2 weeks
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31775
2021-09-08 08:37:11 -03:00
Justin Hibbits eb937f67f8 powerpc: Fix typo in thread register copy
Should be saving off td0's register's, not td's.
2021-09-04 11:44:02 -05:00
Brandon Bergren 35a1aa5f9c [PowerPC] Fix outdated FP regs on fork(2) and friends
Summary:
Failure to update the FP / vector state was causing daemon(3) to violate C ABI by failing to preserve nonvolatile registers.

This was causing a weird issue where moused was not working on PowerBook G4s when daemonizing, but was working fine when running it foreground.

Force saving off the same state that cpu_switch() does in cases where we are about to copy a thread.

MFC after: 1 week
Sponsored by: Tag1 Consulting, Inc.

Test Plan:
```
/*
 * Test for ABI violation due to side effects of daemon(3).
 *
 * NOTE: Compile with -O2 to see the effect.
 */
/* Allow compiling for Linux too. */

static double test = 1234.56f;

/*
 * This contrivance coerces clang to not bounce the double
 * off of memory again in main.
 */
void __attribute__((noinline))
print_double(int j1, int j2, double d)
{
	printf("%f\n", d);
}

int
main(int argc, char *argv[])
{
	print_double(0, 0, test);

	if (daemon(0, 1)) {
	}
	/* Compiler assumes nonvolatile regs are intact... */
	print_double(0, 0, test);
	return(0);
}
```

Working output:
```
1234.560059
1234.560059
```

Output in broken case:
```
1234.560059
0.0
```

Reviewers: #powerpc

Subscribers: jhibbits, luporl, alfredo

Tags: #powerpc

Differential Revision: https://reviews.freebsd.org/D29851
2021-09-04 11:33:03 -05:00
Andrew Turner b792434150 Create sys/reg.h for the common code previously in machine/reg.h
Move the common kernel function signatures from machine/reg.h to a new
sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2).

Reviewed by:	imp, markj
Sponsored by:	DARPA, AFRL (original work)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19830
2021-08-30 12:50:53 +01:00
Mateusz Guzik 11cb9a096c powerpc: retire bzero
Unused since ba96f37758 ("Use __builtin for various mem* and b* (e.g. bzero)
routines.")

Reviewed by:	jhibbits
Sponsored by:   Rubicon Communications, LLC ("Netgate")
2021-08-23 18:38:05 +00:00
Justin Hibbits 5ae48eb998 powerpc/pseries: Allow radix pmap in pseries for ISA 3.0
ISA 3.0 allows for nested radix translations with minimal to no
involvement of the hypervisor.  This should make pseries signficantly
faster on POWER9 pseries instances, as fewer hypercalls are needed to
manage pmap now.

MFC after:	2 weeks
Relnotes:	yes
2021-08-11 19:07:04 -05:00
Konstantin Belousov 041b7317f7 Add pmap_vm_page_alloc_check()
which is the place to put MD asserts about allocated pages.

On amd64, verify that allocated page does not belong to the kernel
(text, data) or early allocated pages.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31121
2021-07-31 16:53:42 +03:00
Leandro Lupori 7844e5a4fc powerpc: change mfpvr return type to uint32_t
As the Processor Version Register (PVR) is a 32-bit PowerPC
register, change mfpvr() return type to match it and avoid
type casts on its callers.

Suggested by:		jhibbits
Reviewed by:		jhibbits, imp
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31332
2021-07-28 14:08:19 -03:00
Leandro Lupori b48a2770d4 powerpc64: add Power8 and Power9 PMCs
Add support to allocate Power8 and 9 PMCs.

Submitted by:		Leonardo Bianconi <leonardo.bianconi@eldorado.org.br>
Reviewed by:		mhorne
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31109
2021-07-26 10:27:23 -03:00