sync with OpenBSD -current

This commit is contained in:
purplerain 2024-07-16 03:02:11 +00:00
parent bc7421a947
commit 4cca26dc5a
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
120 changed files with 4168 additions and 640 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_machdep.c,v 1.28 2024/06/26 01:40:49 jsg Exp $ */
/* $OpenBSD: vmm_machdep.c,v 1.29 2024/07/14 07:57:42 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -126,7 +126,7 @@ int svm_fault_page(struct vcpu *, paddr_t);
int vmx_fault_page(struct vcpu *, paddr_t);
int vmx_handle_np_fault(struct vcpu *);
int svm_handle_np_fault(struct vcpu *);
int vmx_mprotect_ept(vm_map_t, paddr_t, paddr_t, int);
int vmx_mprotect_ept(struct vcpu *, vm_map_t, paddr_t, paddr_t, int);
pt_entry_t *vmx_pmap_find_pte_ept(pmap_t, paddr_t);
int vmm_alloc_vpid(uint16_t *);
void vmm_free_vpid(uint16_t);
@ -777,7 +777,8 @@ vm_mprotect_ept(struct vm_mprotect_ept_params *vmep)
}
if (vmm_softc->mode == VMM_MODE_EPT)
ret = vmx_mprotect_ept(vm->vm_map, sgpa, sgpa + size, prot);
ret = vmx_mprotect_ept(vcpu, vm->vm_map, sgpa, sgpa + size,
prot);
else if (vmm_softc->mode == VMM_MODE_RVI) {
pmap_write_protect(vm->vm_map->pmap, sgpa, sgpa + size, prot);
/* XXX requires a invlpga */
@ -799,7 +800,8 @@ out_nolock:
* required.
*/
int
vmx_mprotect_ept(vm_map_t vm_map, paddr_t sgpa, paddr_t egpa, int prot)
vmx_mprotect_ept(struct vcpu *vcpu, vm_map_t vm_map, paddr_t sgpa, paddr_t egpa,
int prot)
{
struct vmx_invept_descriptor vid;
pmap_t pmap;
@ -859,7 +861,7 @@ vmx_mprotect_ept(vm_map_t vm_map, paddr_t sgpa, paddr_t egpa, int prot)
vid.vid_eptp = pmap->eptp;
DPRINTF("%s: flushing EPT TLB for EPTP 0x%llx\n", __func__,
vid.vid_eptp);
invept(IA32_VMX_INVEPT_SINGLE_CTX, &vid);
invept(vcpu->vc_vmx_invept_op, &vid);
}
KERNEL_UNLOCK();
@ -2948,6 +2950,10 @@ vcpu_init_vmx(struct vcpu *vcpu)
ret = EINVAL;
goto exit;
}
if (msr & IA32_EPT_VPID_CAP_INVEPT_CONTEXT)
vcpu->vc_vmx_invept_op = IA32_VMX_INVEPT_SINGLE_CTX;
else
vcpu->vc_vmx_invept_op = IA32_VMX_INVEPT_GLOBAL_CTX;
if (msr & IA32_EPT_VPID_CAP_WB) {
/* WB cache type supported */
@ -3896,6 +3902,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
struct schedstate_percpu *spc;
struct vmx_msr_store *msr_store;
struct vmx_invvpid_descriptor vid;
struct vmx_invept_descriptor vid_ept;
uint64_t cr0, eii, procbased, int_st;
u_long s;
@ -3940,14 +3947,6 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
}
memset(&vcpu->vc_exit, 0, sizeof(vcpu->vc_exit));
/* Host CR3 */
cr3 = rcr3();
if (vmwrite(VMCS_HOST_IA32_CR3, cr3)) {
printf("%s: vmwrite(0x%04X, 0x%llx)\n", __func__,
VMCS_HOST_IA32_CR3, cr3);
return (EINVAL);
}
/* Handle vmd(8) injected interrupts */
/* Is there an interrupt pending injection? */
if (vcpu->vc_inject.vie_type == VCPU_INJECT_INTR) {
@ -4001,6 +4000,22 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
ci = curcpu();
vcpu->vc_last_pcpu = ci;
/* Invalidate EPT cache. */
vid_ept.vid_reserved = 0;
vid_ept.vid_eptp = vcpu->vc_parent->vm_map->pmap->eptp;
if (invept(vcpu->vc_vmx_invept_op, &vid_ept)) {
printf("%s: invept\n", __func__);
return (EINVAL);
}
/* Host CR3 */
cr3 = rcr3();
if (vmwrite(VMCS_HOST_IA32_CR3, cr3)) {
printf("%s: vmwrite(0x%04X, 0x%llx)\n", __func__,
VMCS_HOST_IA32_CR3, cr3);
return (EINVAL);
}
setregion(&gdt, ci->ci_gdt, GDT_SIZE - 1);
if (gdt.rd_base == 0) {
printf("%s: setregion\n", __func__);

View file

@ -0,0 +1,7 @@
/* $OpenBSD: elf.h,v 1.1 2024/07/14 09:48:48 jca Exp $ */
/*
* This file is in the public domain.
*/
/* Nothing for now */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: specialreg.h,v 1.113 2024/06/24 21:22:14 bluhm Exp $ */
/* $OpenBSD: specialreg.h,v 1.114 2024/07/14 07:57:42 dv Exp $ */
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
@ -1117,6 +1117,8 @@
#define IA32_EPT_VPID_CAP_PAGE_WALK_4 (1ULL << 6)
#define IA32_EPT_VPID_CAP_WB (1ULL << 14)
#define IA32_EPT_VPID_CAP_AD_BITS (1ULL << 21)
#define IA32_EPT_VPID_CAP_INVEPT_CONTEXT (1ULL << 25)
#define IA32_EPT_VPID_CAP_INVEPT_ALL (1ULL << 26)
#define IA32_EPT_PAGING_CACHE_TYPE_UC 0x0
#define IA32_EPT_PAGING_CACHE_TYPE_WB 0x6

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmmvar.h,v 1.103 2024/07/10 09:27:32 dv Exp $ */
/* $OpenBSD: vmmvar.h,v 1.104 2024/07/14 07:57:42 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -886,6 +886,7 @@ struct vcpu {
uint32_t vc_vmx_vmcs_state; /* [a] */
#define VMCS_CLEARED 0
#define VMCS_LAUNCHED 1
uint64_t vc_vmx_invept_op;
/* SVM only (all requiring [v]) */
vaddr_t vc_svm_hsa_va;

View file

@ -0,0 +1,77 @@
/* $OpenBSD: elf.h,v 1.1 2024/07/14 09:48:48 jca Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2001 David E. O'Brien
* Copyright (c) 1996-1997 John D. Polstra.
* All rights reserved.
*
* 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_ELF_H_
#define _MACHINE_ELF_H_
/*
* ELF definitions for the ARM architecture.
*/
#ifdef _KERNEL
# define __HAVE_CPU_HWCAP
# define __HAVE_CPU_HWCAP2
extern unsigned long hwcap, hwcap2;
#endif /* _KERNEL */
/* Flags passed in AT_HWCAP. */
#define HWCAP_SWP 0x00000001 /* Unsupported, never set. */
#define HWCAP_HALF 0x00000002 /* Always set. */
#define HWCAP_THUMB 0x00000004
#define HWCAP_26BIT 0x00000008 /* Unsupported, never set. */
#define HWCAP_FAST_MULT 0x00000010 /* Always set. */
#define HWCAP_FPA 0x00000020 /* Unsupported, never set. */
#define HWCAP_VFP 0x00000040
#define HWCAP_EDSP 0x00000080 /* Always set for ARMv6+. */
#define HWCAP_JAVA 0x00000100 /* Unsupported, never set. */
#define HWCAP_IWMMXT 0x00000200 /* Unsupported, never set. */
#define HWCAP_CRUNCH 0x00000400 /* Unsupported, never set. */
#define HWCAP_THUMBEE 0x00000800
#define HWCAP_NEON 0x00001000
#define HWCAP_VFPv3 0x00002000
#define HWCAP_VFPv3D16 0x00004000
#define HWCAP_TLS 0x00008000 /* Always set for ARMv6+. */
#define HWCAP_VFPv4 0x00010000
#define HWCAP_IDIVA 0x00020000
#define HWCAP_IDIVT 0x00040000
#define HWCAP_VFPD32 0x00080000
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
#define HWCAP_LPAE 0x00100000
#define HWCAP_EVTSTRM 0x00200000 /* Not implemented yet. */
/* Flags passed in AT_HWCAP2. */
#define HWCAP2_AES 0x00000001
#define HWCAP2_PMULL 0x00000002
#define HWCAP2_SHA1 0x00000004
#define HWCAP2_SHA2 0x00000008
#define HWCAP2_CRC32 0x00000010
#endif /* !_MACHINE_ELF_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.c,v 1.125 2024/07/11 12:07:39 kettenis Exp $ */
/* $OpenBSD: cpu.c,v 1.126 2024/07/14 09:48:48 jca Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
@ -32,6 +32,7 @@
#include <uvm/uvm.h>
#include <machine/fdt.h>
#include <machine/elf.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_clock.h>
@ -741,6 +742,10 @@ cpu_identify(struct cpu_info *ci)
printf("%sAtomic", sep);
sep = ",";
arm64_has_lse = 1;
/*
* XXX should be populated and sanitized like cpu_sysctl() does
*/
hwcap |= HWCAP_ATOMICS;
}
if (ID_AA64ISAR0_CRC32(id) >= ID_AA64ISAR0_CRC32_BASE) {

View file

@ -0,0 +1,121 @@
/*-
* Copyright (c) 1996-1997 John D. Polstra.
* All rights reserved.
*
* 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_ELF_H_
#define _MACHINE_ELF_H_
/*
* ELF definitions for the AArch64 architecture.
*/
#ifdef _KERNEL
# define __HAVE_CPU_HWCAP
# define __HAVE_CPU_HWCAP2
extern unsigned long hwcap, hwcap2;
#endif /* _KERNEL */
/* HWCAP */
#define HWCAP_FP 0x00000001
#define HWCAP_ASIMD 0x00000002
#define HWCAP_EVTSTRM 0x00000004
#define HWCAP_AES 0x00000008
#define HWCAP_PMULL 0x00000010
#define HWCAP_SHA1 0x00000020
#define HWCAP_SHA2 0x00000040
#define HWCAP_CRC32 0x00000080
#define HWCAP_ATOMICS 0x00000100
#define HWCAP_FPHP 0x00000200
#define HWCAP_ASIMDHP 0x00000400
#define HWCAP_CPUID 0x00000800
#define HWCAP_ASIMDRDM 0x00001000
#define HWCAP_JSCVT 0x00002000
#define HWCAP_FCMA 0x00004000
#define HWCAP_LRCPC 0x00008000
#define HWCAP_DCPOP 0x00010000
#define HWCAP_SHA3 0x00020000
#define HWCAP_SM3 0x00040000
#define HWCAP_SM4 0x00080000
#define HWCAP_ASIMDDP 0x00100000
#define HWCAP_SHA512 0x00200000
#define HWCAP_SVE 0x00400000
#define HWCAP_ASIMDFHM 0x00800000
#define HWCAP_DIT 0x01000000
#define HWCAP_USCAT 0x02000000
#define HWCAP_ILRCPC 0x04000000
#define HWCAP_FLAGM 0x08000000
#define HWCAP_SSBS 0x10000000
#define HWCAP_SB 0x20000000
#define HWCAP_PACA 0x40000000
#define HWCAP_PACG 0x80000000
/* HWCAP2 */
#define HWCAP2_DCPODP 0x0000000000000001ul
#define HWCAP2_SVE2 0x0000000000000002ul
#define HWCAP2_SVEAES 0x0000000000000004ul
#define HWCAP2_SVEPMULL 0x0000000000000008ul
#define HWCAP2_SVEBITPERM 0x0000000000000010ul
#define HWCAP2_SVESHA3 0x0000000000000020ul
#define HWCAP2_SVESM4 0x0000000000000040ul
#define HWCAP2_FLAGM2 0x0000000000000080ul
#define HWCAP2_FRINT 0x0000000000000100ul
#define HWCAP2_SVEI8MM 0x0000000000000200ul
#define HWCAP2_SVEF32MM 0x0000000000000400ul
#define HWCAP2_SVEF64MM 0x0000000000000800ul
#define HWCAP2_SVEBF16 0x0000000000001000ul
#define HWCAP2_I8MM 0x0000000000002000ul
#define HWCAP2_BF16 0x0000000000004000ul
#define HWCAP2_DGH 0x0000000000008000ul
#define HWCAP2_RNG 0x0000000000010000ul
#define HWCAP2_BTI 0x0000000000020000ul
#define HWCAP2_MTE 0x0000000000040000ul
#define HWCAP2_ECV 0x0000000000080000ul
#define HWCAP2_AFP 0x0000000000100000ul
#define HWCAP2_RPRES 0x0000000000200000ul
#define HWCAP2_MTE3 0x0000000000400000ul
#define HWCAP2_SME 0x0000000000800000ul
#define HWCAP2_SME_I16I64 0x0000000001000000ul
#define HWCAP2_SME_F64F64 0x0000000002000000ul
#define HWCAP2_SME_I8I32 0x0000000004000000ul
#define HWCAP2_SME_F16F32 0x0000000008000000ul
#define HWCAP2_SME_B16F32 0x0000000010000000ul
#define HWCAP2_SME_F32F32 0x0000000020000000ul
#define HWCAP2_SME_FA64 0x0000000040000000ul
#define HWCAP2_WFXT 0x0000000080000000ul
#define HWCAP2_EBF16 0x0000000100000000ul
#define HWCAP2_SVE_EBF16 0x0000000200000000ul
#define HWCAP2_CSSC 0x0000000400000000ul
#define HWCAP2_RPRFM 0x0000000800000000ul
#define HWCAP2_SVE2P1 0x0000001000000000ul
#define HWCAP2_SME2 0x0000002000000000ul
#define HWCAP2_SME2P1 0x0000004000000000ul
#define HWCAP2_SME_I16I32 0x0000008000000000ul
#define HWCAP2_SME_BI32I32 0x0000010000000000ul
#define HWCAP2_SME_B16B16 0x0000020000000000ul
#define HWCAP2_SME_F16F16 0x0000040000000000ul
#define HWCAP2_MOPS 0x0000080000000000ul
#define HWCAP2_HBC 0x0000100000000000ul
#endif /* !_MACHINE_ELF_H_ */

View file

@ -0,0 +1,3 @@
/* $OpenBSD: elf.h,v 1.1 2024/07/14 19:33:59 miod Exp $ */
#include <arm/elf.h>

View file

@ -0,0 +1,7 @@
/* $OpenBSD: elf.h,v 1.1 2024/07/14 09:48:48 jca Exp $ */
/*
* This file is in the public domain.
*/
/* Nothing for now */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpi.c,v 1.433 2024/07/02 08:27:04 kettenis Exp $ */
/* $OpenBSD: acpi.c,v 1.435 2024/07/14 13:58:57 jmatthew Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@ -65,6 +65,7 @@ void acpi_pci_set_powerstate(pci_chipset_tag_t, pcitag_t, int, int);
int acpi_pci_notify(struct aml_node *, int, void *);
int acpi_submatch(struct device *, void *, void *);
int acpi_noprint(void *, const char *);
int acpi_print(void *, const char *);
void acpi_map_pmregs(struct acpi_softc *);
@ -756,9 +757,10 @@ acpi_pci_min_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
void
acpi_pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int state, int pre)
{
#if NACPIPWRRES > 0
struct acpi_softc *sc = acpi_softc;
#if NACPIPWRRES > 0
struct acpi_pwrres *pr;
#endif
struct acpi_pci *pdev;
int bus, dev, fun;
char name[5];
@ -769,10 +771,15 @@ acpi_pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int state, int pre)
break;
}
/* XXX Add a check to discard nodes without Power Resources? */
if (pdev == NULL)
return;
if (state != ACPI_STATE_D0 && !pre) {
snprintf(name, sizeof(name), "_PS%d", state);
aml_evalname(sc, pdev->node, name, 0, NULL, NULL);
}
#if NACPIPWRRES > 0
SIMPLEQ_FOREACH(pr, &sc->sc_pwrresdevs, p_next) {
if (pr->p_node != pdev->node)
continue;
@ -811,6 +818,9 @@ acpi_pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int state, int pre)
}
#endif /* NACPIPWRRES > 0 */
if (state == ACPI_STATE_D0 && pre)
aml_evalname(sc, pdev->node, "_PS0", 0, NULL, NULL);
}
int
@ -1307,6 +1317,12 @@ acpi_submatch(struct device *parent, void *match, void *aux)
return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
int
acpi_noprint(void *aux, const char *pnp)
{
return (QUIET);
}
int
acpi_print(void *aux, const char *pnp)
{
@ -3001,6 +3017,12 @@ const char *acpi_isa_hids[] = {
NULL
};
/* Overly abundant devices to avoid printing details for */
const char *acpi_quiet_hids[] = {
"ACPI0007",
NULL
};
void
acpi_attach_deps(struct acpi_softc *sc, struct aml_node *node)
{
@ -3220,7 +3242,10 @@ acpi_foundhid(struct aml_node *node, void *arg)
if (!node->parent->attached) {
node->parent->attached = 1;
config_found(self, &aaa, acpi_print);
if (acpi_matchhids(&aaa, acpi_quiet_hids, "none"))
config_found(self, &aaa, acpi_noprint);
else
config_found(self, &aaa, acpi_print);
}
return (0);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpicpu.c,v 1.93 2024/06/07 16:53:35 kettenis Exp $ */
/* $OpenBSD: acpicpu.c,v 1.94 2024/07/14 14:04:16 jmatthew Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
@ -654,6 +654,9 @@ acpicpu_match(struct device *parent, void *match, void *aux)
struct acpi_attach_args *aa = aux;
struct cfdata *cf = match;
struct acpi_softc *acpi = (struct acpi_softc *)parent;
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
int64_t uid;
if (acpi_matchhids(aa, acpicpu_hids, cf->cf_driver->cd_name) &&
aa->aaa_node && aa->aaa_node->value &&
@ -663,7 +666,15 @@ acpicpu_match(struct device *parent, void *match, void *aux)
* so we won't attach any Processor() nodes.
*/
acpi->sc_skip_processor = 1;
return (1);
/* Only match if we can find a CPU with the right ID */
if (aml_evalinteger(acpi, aa->aaa_node, "_UID", 0,
NULL, &uid) == 0)
CPU_INFO_FOREACH(cii, ci)
if (ci->ci_acpi_proc_id == uid)
return (1);
return (0);
}
/* sanity */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpipwrres.c,v 1.13 2023/02/18 14:32:02 dv Exp $ */
/* $OpenBSD: acpipwrres.c,v 1.14 2024/07/14 10:48:55 kettenis Exp $ */
/*
* Copyright (c) 2013 Martin Pieuchot <mpi@openbsd.org>
@ -33,6 +33,7 @@
int acpipwrres_match(struct device *, void *, void *);
void acpipwrres_attach(struct device *, struct device *, void *);
int acpipwrres_activate(struct device *, int);
#ifdef ACPIPWRRES_DEBUG
#define DPRINTF(x) printf x
@ -66,7 +67,8 @@ struct acpipwrres_consumer {
};
const struct cfattach acpipwrres_ca = {
sizeof(struct acpipwrres_softc), acpipwrres_match, acpipwrres_attach
sizeof(struct acpipwrres_softc), acpipwrres_match, acpipwrres_attach,
NULL, acpipwrres_activate
};
struct cfdriver acpipwrres_cd = {
@ -140,6 +142,23 @@ acpipwrres_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
}
int
acpipwrres_activate(struct device *self, int act)
{
struct acpipwrres_softc *sc = (struct acpipwrres_softc *)self;
switch (act) {
case DVACT_SUSPEND:
if (sc->sc_cons_ref == 0 && sc->sc_state != ACPIPWRRES_OFF) {
aml_evalname(sc->sc_acpi, sc->sc_devnode, "_OFF", 0,
NULL, NULL);
sc->sc_state = ACPIPWRRES_OFF;
}
break;
}
return 0;
}
int
acpipwrres_ref_incr(struct acpipwrres_softc *sc, struct aml_node *node)
{
@ -149,9 +168,11 @@ acpipwrres_ref_incr(struct acpipwrres_softc *sc, struct aml_node *node)
DPRINTF(("%s: dev %s ON %d\n", DEVNAME(sc), node->name,
sc->sc_cons_ref));
if (sc->sc_cons_ref++ == 0)
if (sc->sc_cons_ref++ == 0) {
aml_evalname(sc->sc_acpi, sc->sc_devnode, "_ON", 0,
NULL, NULL);
sc->sc_state = ACPIPWRRES_ON;
}
return (0);
}
@ -165,9 +186,11 @@ acpipwrres_ref_decr(struct acpipwrres_softc *sc, struct aml_node *node)
DPRINTF(("%s: dev %s OFF %d\n", DEVNAME(sc), node->name,
sc->sc_cons_ref));
if (--sc->sc_cons_ref == 0)
if (--sc->sc_cons_ref == 0) {
aml_evalname(sc->sc_acpi, sc->sc_devnode, "_OFF", 0,
NULL, NULL);
sc->sc_state = ACPIPWRRES_OFF;
}
return (0);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: qcgpio.c,v 1.10 2024/07/04 18:35:36 patrick Exp $ */
/* $OpenBSD: qcgpio.c,v 1.11 2024/07/15 15:33:54 mglocker Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
*
@ -237,6 +237,8 @@ qcgpio_x1e80100_pin_map(int pin, bus_size_t *off)
return pin;
case 0x180:
return 67;
case 0x380:
return 33;
case 0x3c0:
return 3;
default:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dwmshc.c,v 1.7 2024/05/26 22:04:52 kettenis Exp $ */
/* $OpenBSD: dwmshc.c,v 1.8 2024/07/15 09:56:30 patrick Exp $ */
/*
* Copyright (c) 2023 David Gwynne <dlg@openbsd.org>
@ -101,6 +101,8 @@
#define EMMC_DLL_TXCLK 0x808
#define EMMC_DLL_TXCLK_TX_TAP_NUM_SHIFT 0
#define EMMC_DLL_TXCLK_TX_TAP_NUM_MASK 0x1f
#define EMMC_DLL_TXCLK_TX_TAP_NUM_90_DEG 0x8
#define EMMC_DLL_TXCLK_TX_TAP_NUM_DEFAULT 0x10
#define EMMC_DLL_TXCLK_TX_TAP_VALUE_SHIFT 8
#define EMMC_DLL_TXCLK_TX_TAP_VALUE_MASK 0xff
#define EMMC_DLL_TXCLK_TX_DELAY_SHIFT 16
@ -112,7 +114,7 @@
#define EMMC_DLL_STRBIN 0x80c
#define EMMC_DLL_STRBIN_TAP_NUM_SHIFT 0
#define EMMC_DLL_STRBIN_TAP_NUM_MASK 0x1f
#define EMMC_DLL_STRBIN_TAP_NUM_DEFAULT 0x8
#define EMMC_DLL_STRBIN_TAP_NUM_90_DEG 0x8
#define EMMC_DLL_STRBIN_TAP_VALUE_SHIFT 8
#define EMMC_DLL_STRBIN_TAP_VALUE_MASK 0xff
#define EMMC_DLL_STRBIN_DELAY_NUM_SHIFT 16
@ -122,6 +124,20 @@
#define EMMC_DLL_STRBIN_TAP_VALUE_SEL (1U << 25)
#define EMMC_DLL_STRBIN_DELAY_NUM_SEL (1U << 26)
#define EMMC_DLL_STRBIN_DELAY_ENA (1U << 27)
#define EMMC_DLL_CMDOUT 0x810
#define EMMC_DLL_CMDOUT_TAP_NUM_SHIFT 0
#define EMMC_DLL_CMDOUT_TAP_NUM_MASK 0x1f
#define EMMC_DLL_CMDOUT_TAP_NUM_90_DEG 0x8
#define EMMC_DLL_CMDOUT_TAP_VALUE_SHIFT 8
#define EMMC_DLL_CMDOUT_TAP_VALUE_MASK 0xff
#define EMMC_DLL_CMDOUT_DELAY_NUM_SHIFT 16
#define EMMC_DLL_CMDOUT_DELAY_NUM_MASK 0xff
#define EMMC_DLL_CMDOUT_TAP_NUM_SEL (1U << 24)
#define EMMC_DLL_CMDOUT_TAP_VALUE_SEL (1U << 25)
#define EMMC_DLL_CMDOUT_DELAY_NUM_SEL (1U << 26)
#define EMMC_DLL_CMDOUT_DELAY_ENA (1U << 27)
#define EMMC_DLL_CMDOUT_SRC_SEL (1U << 28)
#define EMMC_DLL_CMDOUT_EN_SRC_SEL (1U << 29)
#define EMMC_DLL_STATUS0 0x840
#define EMMC_DLL_STATUS0_DLL_LOCK_VALUE_SHIFT 0
#define EMMC_DLL_STATUS0_DLL_LOCK_VALUE_MASK 0xff
@ -182,7 +198,8 @@ dwmshc_match(struct device *parent, void *match, void *aux)
{
struct fdt_attach_args *faa = aux;
return (OF_is_compatible(faa->fa_node, "rockchip,rk3568-dwcmshc"));
return (OF_is_compatible(faa->fa_node, "rockchip,rk3568-dwcmshc") ||
OF_is_compatible(faa->fa_node, "rockchip,rk3588-dwcmshc"));
}
static void
dwmshc_attach(struct device *parent, struct device *self, void *aux)
@ -303,7 +320,7 @@ static void
dwmshc_clock_post(struct sdhc_softc *sdhc, int freq, int timing)
{
struct dwmshc_softc *sc = (struct dwmshc_softc *)sdhc;
uint32_t txclk_tapnum = EMMC_DLL_STRBIN_DELAY_NUM_DEFAULT;
uint32_t txclk_tapnum = EMMC_DLL_TXCLK_TX_TAP_NUM_DEFAULT;
clock_set_frequency(sc->sc_node, 0, freq * 1000);
@ -324,8 +341,11 @@ dwmshc_clock_post(struct sdhc_softc *sdhc, int freq, int timing)
delay(1);
dwmshc_wr4(sc, EMMC_DLL_CTRL, 0);
dwmshc_wr4(sc, EMMC_DLL_RXCLK, EMMC_DLL_RXCLK_RX_CLK_OUT_SEL |
/* rk3568 */ EMMC_DLL_RXCLK_RX_CLK_SRC_SEL);
if (OF_is_compatible(sc->sc_node, "rockchip,rk3568-dwcmshc"))
dwmshc_wr4(sc, EMMC_DLL_RXCLK, EMMC_DLL_RXCLK_RX_CLK_OUT_SEL |
EMMC_DLL_RXCLK_RX_CLK_SRC_SEL);
else
dwmshc_wr4(sc, EMMC_DLL_RXCLK, EMMC_DLL_RXCLK_RX_CLK_OUT_SEL);
dwmshc_wr4(sc, EMMC_DLL_CTRL, EMMC_DLL_CTRL_DLL_START |
0x5 << EMMC_DLL_CTRL_DLL_START_POINT_SHIFT |
0x2 << EMMC_DLL_CTRL_DLL_INCREMENT_SHIFT);
@ -341,7 +361,18 @@ dwmshc_clock_post(struct sdhc_softc *sdhc, int freq, int timing)
txclk_tapnum = OF_getpropint(sc->sc_node,
"rockchip,txclk-tapnum", txclk_tapnum);
/* XXX rk3588 hs400 */
#ifdef notyet
if (OF_is_compatible(sc->sc_node, "rockchip,rk3588-dwcmshc") &&
timing == SDMMC_TIMING_MMC_HS400) {
txclk_tapnum = EMMC_DLL_TXCLK_TX_TAP_NUM_90_DEG;
dwmshc_wr4(sc, EMMC_DLL_CMDOUT,
EMMC_DLL_CMDOUT_TAP_NUM_90_DEG |
EMMC_DLL_CMDOUT_TAP_NUM_SEL |
EMMC_DLL_CMDOUT_DELAY_ENA |
EMMC_DLL_CMDOUT_SRC_SEL |
EMMC_DLL_CMDOUT_EN_SRC_SEL);
}
#endif
}
dwmshc_wr4(sc, EMMC_DLL_TXCLK, EMMC_DLL_TXCLK_TX_CLK_OUT_SEL |
@ -349,7 +380,7 @@ dwmshc_clock_post(struct sdhc_softc *sdhc, int freq, int timing)
txclk_tapnum << EMMC_DLL_TXCLK_TX_TAP_NUM_SHIFT);
dwmshc_wr4(sc, EMMC_DLL_STRBIN, EMMC_DLL_STRBIN_DELAY_ENA |
EMMC_DLL_STRBIN_TAP_NUM_SEL |
(EMMC_DLL_STRBIN_TAP_NUM_DEFAULT <<
(EMMC_DLL_STRBIN_TAP_NUM_90_DEG <<
EMMC_DLL_STRBIN_TAP_NUM_SHIFT));
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rkclock.c,v 1.89 2024/06/11 09:15:33 kettenis Exp $ */
/* $OpenBSD: rkclock.c,v 1.90 2024/07/15 09:54:38 patrick Exp $ */
/*
* Copyright (c) 2017, 2018 Mark Kettenis <kettenis@openbsd.org>
*
@ -4217,6 +4217,20 @@ const struct rkclock rk3588_clocks[] = {
{ RK3588_CLK_GPU_SRC },
SET_PARENT
},
{
RK3588_CCLK_EMMC, RK3588_CRU_CLKSEL_CON(77),
SEL(15, 14), DIV(13, 8),
{ RK3588_PLL_GPLL, RK3588_PLL_CPLL, RK3588_XIN24M }
},
{
RK3588_BCLK_EMMC, RK3588_CRU_CLKSEL_CON(78),
SEL(5, 5), DIV(4, 0),
{ RK3588_PLL_GPLL, RK3588_PLL_CPLL }
},
{
RK3588_TMCLK_EMMC, 0, 0, 0,
{ RK3588_XIN24M }
},
{
RK3588_CLK_GMAC_125M, RK3588_CRU_CLKSEL_CON(83),
SEL(15, 15), DIV(14, 8),
@ -4567,6 +4581,26 @@ rk3588_reset(void *cookie, uint32_t *cells, int on)
reg = RK3588_CRU_SOFTRST_CON(12);
bit = 1;
break;
case RK3588_SRST_H_EMMC:
reg = RK3588_CRU_SOFTRST_CON(31);
bit = 4;
break;
case RK3588_SRST_A_EMMC:
reg = RK3588_CRU_SOFTRST_CON(31);
bit = 5;
break;
case RK3588_SRST_C_EMMC:
reg = RK3588_CRU_SOFTRST_CON(31);
bit = 6;
break;
case RK3588_SRST_B_EMMC:
reg = RK3588_CRU_SOFTRST_CON(31);
bit = 7;
break;
case RK3588_SRST_T_EMMC:
reg = RK3588_CRU_SOFTRST_CON(31);
bit = 8;
break;
case RK3588_SRST_A_GMAC0:
reg = RK3588_CRU_SOFTRST_CON(32);
bit = 10;

View file

@ -480,6 +480,11 @@
#define RK3588_ACLK_LOW_TOP_ROOT 258
#define RK3588_CLK_GPU_SRC 261
#define RK3588_CLK_GPU 262
#define RK3588_HCLK_EMMC 298
#define RK3588_ACLK_EMMC 299
#define RK3588_CCLK_EMMC 300
#define RK3588_BCLK_EMMC 301
#define RK3588_TMCLK_EMMC 302
#define RK3588_CLK_GMAC_125M 310
#define RK3588_CCLK_SRC_SDIO 395
#define RK3588_ACLK_VOP_ROOT 600
@ -513,6 +518,11 @@
#define RK3588_SRST_P_TSADC 86
#define RK3588_SRST_TSADC 87
#define RK3588_SRST_H_EMMC 278
#define RK3588_SRST_A_EMMC 279
#define RK3588_SRST_C_EMMC 280
#define RK3588_SRST_B_EMMC 281
#define RK3588_SRST_T_EMMC 282
#define RK3588_SRST_A_GMAC0 291
#define RK3588_SRST_A_GMAC1 292
#define RK3588_SRST_PCIE0_POWER_UP 294

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ichiic.c,v 1.55 2024/05/24 06:02:53 jsg Exp $ */
/* $OpenBSD: ichiic.c,v 1.56 2024/07/16 01:14:23 jsg Exp $ */
/*
* Copyright (c) 2005, 2006 Alexander Yurchenko <grange@openbsd.org>
@ -108,6 +108,7 @@ const struct pci_matchid ichiic_ids[] = {
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801JI_SMB },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APOLLOLAKE_SMB },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ATOMC2000_PCU_SMB },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C3000_SMB_2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BAYTRAIL_SMB },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_BRASWELL_SMB },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_SMB },

View file

@ -1,4 +1,4 @@
/* $OpenBSD: exec_elf.c,v 1.186 2024/04/02 08:39:16 deraadt Exp $ */
/* $OpenBSD: exec_elf.c,v 1.188 2024/07/14 11:36:54 jca Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
@ -89,6 +89,7 @@
#include <machine/reg.h>
#include <machine/exec.h>
#include <machine/elf.h>
int elf_load_file(struct proc *, char *, struct exec_package *,
struct elf_args *);
@ -923,6 +924,14 @@ bad:
return (error);
}
#ifdef __HAVE_CPU_HWCAP
unsigned long hwcap;
#endif /* __HAVE_CPU_HWCAP */
#ifdef __HAVE_CPU_HWCAP2
unsigned long hwcap2;
#endif /* __HAVE_CPU_HWCAP2 */
/*
* Phase II of load. It is now safe to load the interpreter. Info collected
* when loading the program is available for setup of the interpreter.
@ -995,6 +1004,18 @@ exec_elf_fixup(struct proc *p, struct exec_package *epp)
a->au_v = ap->arg_entry;
a++;
#ifdef __HAVE_CPU_HWCAP
a->au_id = AUX_hwcap;
a->au_v = hwcap;
a++;
#endif /* __HAVE_CPU_HWCAP */
#ifdef __HAVE_CPU_HWCAP2
a->au_id = AUX_hwcap2;
a->au_v = hwcap2;
a++;
#endif /* __HAVE_CPU_HWCAP2 */
a->au_id = AUX_openbsd_timekeep;
a->au_v = p->p_p->ps_timekeep;
a++;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.337 2024/07/12 17:20:18 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.338 2024/07/14 15:42:23 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -1690,7 +1690,7 @@ somove(struct socket *so, int wait)
* Move only a partial mbuf at maximum splice length or
* if the drain buffer is too small for this large mbuf.
*/
if (!maxreached && so->so_snd.sb_datacc > 0) {
if (!maxreached && sosp->so_snd.sb_datacc > 0) {
len -= size;
break;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.719 2024/06/20 19:25:42 bluhm Exp $ */
/* $OpenBSD: if.c,v 1.720 2024/07/14 18:53:39 bluhm Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@ -3353,6 +3353,7 @@ ifnewlladdr(struct ifnet *ifp)
{
#ifdef INET6
struct ifaddr *ifa;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
#endif
struct ifreq ifrq;
short up;
@ -3378,7 +3379,7 @@ ifnewlladdr(struct ifnet *ifp)
* Update the link-local address. Don't do it if we're
* a router to avoid confusing hosts on the network.
*/
if (ip6_forwarding == 0) {
if (!i_am_router) {
ifa = &in6ifa_ifpforlinklocal(ifp, 0)->ia_ifa;
if (ifa) {
in6_purgeaddr(ifa);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.1202 2024/07/12 09:25:27 bluhm Exp $ */
/* $OpenBSD: pf.c,v 1.1203 2024/07/14 18:53:39 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -7988,7 +7988,7 @@ done:
if (pd.dir == PF_IN) {
int flags = IPV6_REDIRECT;
switch (ip6_forwarding) {
switch (atomic_load_int(&ip6_forwarding)) {
case 2:
SET(flags, IPV6_FORWARDING_IPSEC);
/* FALLTHROUGH */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pf_norm.c,v 1.232 2024/07/04 12:50:08 bluhm Exp $ */
/* $OpenBSD: pf_norm.c,v 1.233 2024/07/14 18:53:39 bluhm Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@ -1013,7 +1013,7 @@ pf_refragment6(struct mbuf **m0, struct m_tag *mtag, struct sockaddr_in6 *dst,
if (ifp == NULL) {
int flags = 0;
switch (ip6_forwarding) {
switch (atomic_load_int(&ip6_forwarding)) {
case 2:
SET(flags, IPV6_FORWARDING_IPSEC);
/* FALLTHROUGH */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_carp.c,v 1.362 2024/06/20 19:25:42 bluhm Exp $ */
/* $OpenBSD: ip_carp.c,v 1.363 2024/07/14 18:53:39 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@ -1287,9 +1287,10 @@ carp_send_na(struct carp_softc *sc)
struct ifaddr *ifa;
struct in6_addr *in6;
static struct in6_addr mcast = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
int flags = ND_NA_FLAG_OVERRIDE;
if (ip6_forwarding != 0)
if (i_am_router)
flags |= ND_NA_FLAG_ROUTER;
TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_icmp.c,v 1.195 2024/07/12 09:25:27 bluhm Exp $ */
/* $OpenBSD: ip_icmp.c,v 1.196 2024/07/14 18:53:39 bluhm Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@ -588,9 +588,9 @@ reflect:
struct sockaddr_in sgw;
struct sockaddr_in ssrc;
struct rtentry *newrt = NULL;
int i_am_router = (atomic_load_int(&ip_forwarding) != 0);
if (icmp_rediraccept == 0 ||
atomic_load_int(&ip_forwarding) != 0)
if (icmp_rediraccept == 0 || i_am_router)
goto freeit;
if (code > 3)
goto badcode;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_input.c,v 1.398 2024/07/12 09:25:27 bluhm Exp $ */
/* $OpenBSD: ip_input.c,v 1.399 2024/07/14 18:53:39 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@ -111,6 +111,10 @@ LIST_HEAD(, ipq) ipq;
int ip_maxqueue = 300;
int ip_frags = 0;
const struct sysctl_bounded_args ipctl_vars_unlocked[] = {
{ IPCTL_FORWARDING, &ip_forwarding, 0, 2 },
};
const struct sysctl_bounded_args ipctl_vars[] = {
#ifdef MROUTING
{ IPCTL_MRTPROTO, &ip_mrtproto, SYSCTL_INT_READONLY },
@ -1799,8 +1803,9 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
NET_UNLOCK();
return (error);
case IPCTL_FORWARDING:
return (sysctl_int_bounded(oldp, oldlenp, newp, newlen,
&ip_forwarding, 0, 2));
return (sysctl_bounded_arr(
ipctl_vars_unlocked, nitems(ipctl_vars_unlocked),
name, namelen, oldp, oldlenp, newp, newlen));
default:
NET_LOCK();
error = sysctl_bounded_arr(ipctl_vars, nitems(ipctl_vars),

View file

@ -1,4 +1,4 @@
/* $OpenBSD: icmp6.c,v 1.253 2024/06/20 19:25:42 bluhm Exp $ */
/* $OpenBSD: icmp6.c,v 1.254 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@ -1228,6 +1228,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
char *lladdr = NULL;
int lladdrlen = 0;
struct rtentry *rt = NULL;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
int is_router;
int is_onlink;
struct in6_addr src6 = ip6->ip6_src;
@ -1241,7 +1242,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
return;
/* if we are router, we don't update route by icmp6 redirect */
if (ip6_forwarding != 0)
if (i_am_router)
goto freeit;
if (!(ifp->if_xflags & IFXF_AUTOCONF6))
goto freeit;
@ -1366,7 +1367,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
/* RFC 2461 8.3 */
nd6_cache_lladdr(ifp, &redtgt6, lladdr, lladdrlen, ND_REDIRECT,
is_onlink ? ND_REDIRECT_ONLINK : ND_REDIRECT_ROUTER);
is_onlink ? ND_REDIRECT_ONLINK : ND_REDIRECT_ROUTER, i_am_router);
if (!is_onlink) { /* better router case. perform rtredirect. */
/* perform rtredirect */
@ -1438,11 +1439,12 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
size_t maxlen;
u_char *p;
struct sockaddr_in6 src_sa;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
icmp6_errcount(ND_REDIRECT, 0);
/* if we are not router, we don't send icmp6 redirect */
if (ip6_forwarding == 0)
if (!i_am_router)
goto fail;
/* sanity check */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_input.c,v 1.264 2024/07/04 12:50:08 bluhm Exp $ */
/* $OpenBSD: ip6_input.c,v 1.265 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@ -416,7 +416,7 @@ ip6_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
SET(flags, IPV6_REDIRECT);
#endif
switch (ip6_forwarding) {
switch (atomic_load_int(&ip6_forwarding)) {
case 2:
SET(flags, IPV6_FORWARDING_IPSEC);
/* FALLTHROUGH */
@ -1443,12 +1443,15 @@ const u_char inet6ctlerrmap[PRC_NCMDS] = {
extern int ip6_mrtproto;
#endif
const struct sysctl_bounded_args ipv6ctl_vars_unlocked[] = {
{ IPV6CTL_FORWARDING, &ip6_forwarding, 0, 2 },
};
const struct sysctl_bounded_args ipv6ctl_vars[] = {
{ IPV6CTL_DAD_PENDING, &ip6_dad_pending, SYSCTL_INT_READONLY },
#ifdef MROUTING
{ IPV6CTL_MRTPROTO, &ip6_mrtproto, SYSCTL_INT_READONLY },
#endif
{ IPV6CTL_FORWARDING, &ip6_forwarding, 0, 2 },
{ IPV6CTL_SENDREDIRECTS, &ip6_sendredirects, 0, 1 },
{ IPV6CTL_DEFHLIM, &ip6_defhlim, 0, 255 },
{ IPV6CTL_MAXFRAGPACKETS, &ip6_maxfragpackets, 0, 1000 },
@ -1568,6 +1571,10 @@ ip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
atomic_inc_long(&rtgeneration);
NET_UNLOCK();
return (error);
case IPV6CTL_FORWARDING:
return (sysctl_bounded_arr(
ipv6ctl_vars_unlocked, nitems(ipv6ctl_vars_unlocked),
name, namelen, oldp, oldlenp, newp, newlen));
default:
NET_LOCK();
error = sysctl_bounded_arr(ipv6ctl_vars, nitems(ipv6ctl_vars),

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nd6.c,v 1.281 2024/06/20 19:25:42 bluhm Exp $ */
/* $OpenBSD: nd6.c,v 1.282 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@ -107,8 +107,8 @@ void nd6_slowtimo(void *);
void nd6_expire(void *);
void nd6_expire_timer(void *);
void nd6_invalidate(struct rtentry *);
void nd6_free(struct rtentry *);
int nd6_llinfo_timer(struct rtentry *);
void nd6_free(struct rtentry *, int);
int nd6_llinfo_timer(struct rtentry *, int);
struct timeout nd6_timer_to;
struct timeout nd6_slowtimo_ch;
@ -264,6 +264,7 @@ nd6_timer(void *unused)
{
struct llinfo_nd6 *ln, *nln;
time_t uptime, expire;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
int secs;
NET_LOCK();
@ -276,7 +277,7 @@ nd6_timer(void *unused)
struct rtentry *rt = ln->ln_rt;
if (rt->rt_expire && rt->rt_expire <= uptime)
if (nd6_llinfo_timer(rt))
if (nd6_llinfo_timer(rt, i_am_router))
continue;
if (rt->rt_expire && rt->rt_expire < expire)
@ -300,7 +301,7 @@ nd6_timer(void *unused)
* Returns 1 if `rt' should no longer be used, 0 otherwise.
*/
int
nd6_llinfo_timer(struct rtentry *rt)
nd6_llinfo_timer(struct rtentry *rt, int i_am_router)
{
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo;
struct sockaddr_in6 *dst = satosin6(rt_key(rt));
@ -346,7 +347,7 @@ nd6_llinfo_timer(struct rtentry *rt)
} else
atomic_sub_int(&ln_hold_total, len);
nd6_free(rt);
nd6_free(rt, i_am_router);
ln = NULL;
}
break;
@ -362,7 +363,7 @@ nd6_llinfo_timer(struct rtentry *rt)
case ND6_LLINFO_PURGE:
/* Garbage Collection(RFC 2461 5.3) */
if (!ND6_LLINFO_PERMANENT(ln)) {
nd6_free(rt);
nd6_free(rt, i_am_router);
ln = NULL;
}
break;
@ -383,7 +384,7 @@ nd6_llinfo_timer(struct rtentry *rt)
nd6_ns_output(ifp, &dst->sin6_addr, &dst->sin6_addr,
&ln->ln_saddr6, 0);
} else {
nd6_free(rt);
nd6_free(rt, i_am_router);
ln = NULL;
}
break;
@ -477,6 +478,7 @@ void
nd6_purge(struct ifnet *ifp)
{
struct llinfo_nd6 *ln, *nln;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
NET_ASSERT_LOCKED_EXCLUSIVE();
@ -492,7 +494,7 @@ nd6_purge(struct ifnet *ifp)
rt->rt_gateway->sa_family == AF_LINK) {
sdl = satosdl(rt->rt_gateway);
if (sdl->sdl_index == ifp->if_index)
nd6_free(rt);
nd6_free(rt, i_am_router);
}
}
}
@ -661,7 +663,7 @@ nd6_invalidate(struct rtentry *rt)
* Free an nd6 llinfo entry.
*/
void
nd6_free(struct rtentry *rt)
nd6_free(struct rtentry *rt, int i_am_router)
{
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo;
struct in6_addr in6 = satosin6(rt_key(rt))->sin6_addr;
@ -671,7 +673,7 @@ nd6_free(struct rtentry *rt)
ifp = if_get(rt->rt_ifidx);
if (ip6_forwarding == 0) {
if (!i_am_router) {
if (ln->ln_router) {
/*
* rt6_flush must be called whether or not the neighbor
@ -1031,7 +1033,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
*/
void
nd6_cache_lladdr(struct ifnet *ifp, const struct in6_addr *from, char *lladdr,
int lladdrlen, int type, int code)
int lladdrlen, int type, int code, int i_am_router)
{
struct rtentry *rt;
struct llinfo_nd6 *ln;
@ -1080,7 +1082,7 @@ nd6_cache_lladdr(struct ifnet *ifp, const struct in6_addr *from, char *lladdr,
return;
if ((rt->rt_flags & (RTF_GATEWAY | RTF_LLINFO)) != RTF_LLINFO) {
fail:
nd6_free(rt);
nd6_free(rt, i_am_router);
rtfree(rt);
return;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nd6.h,v 1.99 2023/05/04 06:56:56 bluhm Exp $ */
/* $OpenBSD: nd6.h,v 1.100 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@ -134,7 +134,7 @@ void nd6_nud_hint(struct rtentry *);
void nd6_rtrequest(struct ifnet *, int, struct rtentry *);
int nd6_ioctl(u_long, caddr_t, struct ifnet *);
void nd6_cache_lladdr(struct ifnet *, const struct in6_addr *, char *,
int, int, int);
int, int, int, int);
int nd6_resolve(struct ifnet *, struct rtentry *, struct mbuf *,
struct sockaddr *, u_char *);
int nd6_need_cache(struct ifnet *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nd6_nbr.c,v 1.152 2024/06/20 19:25:42 bluhm Exp $ */
/* $OpenBSD: nd6_nbr.c,v 1.153 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@ -108,7 +108,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
struct ifaddr *ifa = NULL;
int lladdrlen = 0;
int anycast = 0, proxy = 0, tentative = 0;
int i_am_router = (ip6_forwarding != 0);
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
int tlladdr;
struct nd_opts ndopts;
struct sockaddr_dl *proxydl = NULL;
@ -323,7 +323,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
}
nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, ND_NEIGHBOR_SOLICIT,
0);
0, i_am_router);
nd6_na_output(ifp, &saddr6, &taddr6,
((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) |
@ -559,7 +559,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
int is_override;
char *lladdr = NULL;
int lladdrlen = 0;
int i_am_router = (ip6_forwarding != 0);
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
struct ifaddr *ifa;
struct in6_ifaddr *ifa6;
struct llinfo_nd6 *ln;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: nd6_rtr.c,v 1.170 2023/03/31 19:43:33 bluhm Exp $ */
/* $OpenBSD: nd6_rtr.c,v 1.171 2024/07/14 18:53:39 bluhm Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@ -73,6 +73,7 @@ nd6_rtr_cache(struct mbuf *m, int off, int icmp6len, int icmp6_type)
struct in6_addr saddr6 = ip6->ip6_src;
char *lladdr = NULL;
int lladdrlen = 0;
int i_am_router = (atomic_load_int(&ip6_forwarding) != 0);
struct nd_opts ndopts;
char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
@ -157,7 +158,8 @@ nd6_rtr_cache(struct mbuf *m, int off, int icmp6len, int icmp6_type)
goto bad;
}
nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, icmp6_type, 0);
nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, icmp6_type, 0,
i_am_router);
if_put(ifp);
freeit:

50
sys/sys/auxv.h Normal file
View file

@ -0,0 +1,50 @@
/* $OpenBSD: auxv.h,v 1.1 2024/07/14 09:48:49 jca Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2017 Michal Meloun
* All rights reserved.
*
* 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 _SYS_AUXV_H_
#define _SYS_AUXV_H_
#include <sys/types.h>
#include <machine/elf.h>
/* Values for a_type. */
#define AT_NULL 0 /* Terminates the vector. */
#define AT_IGNORE 1 /* Ignored entry. */
#define AT_PAGESZ 6 /* Page size in bytes. */
#define AT_HWCAP 25 /* CPU feature flags. */
#define AT_HWCAP2 26 /* CPU feature flags 2. */
#define AT_COUNT 27 /* Count of defined aux entry types. */
__BEGIN_DECLS
int elf_aux_info(int aux, void *buf, int buflen);
__END_DECLS
#endif /* !_SYS_AUXV_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: exec_elf.h,v 1.104 2024/06/22 12:26:17 deraadt Exp $ */
/* $OpenBSD: exec_elf.h,v 1.105 2024/07/14 09:48:49 jca Exp $ */
/*
* Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
*
@ -728,6 +728,8 @@ enum AuxID {
AUX_base = 7, /* base addr for ld.so or static PIE */
AUX_flags = 8, /* processor flags */
AUX_entry = 9, /* a.out entry */
AUX_hwcap = 25, /* processor flags */
AUX_hwcap2 = 26, /* processor flags (continued) */
AUX_sun_uid = 2000, /* euid */
AUX_sun_ruid = 2001, /* ruid */
AUX_sun_gid = 2002, /* egid */
@ -821,7 +823,7 @@ extern Elf_Dyn _DYNAMIC[];
/*
* How many entries are in the AuxInfo array we pass to the process?
*/
#define ELF_AUX_ENTRIES 9
#define ELF_AUX_ENTRIES 11
#define ELF_AUX_WORDS (sizeof(AuxInfo) * ELF_AUX_ENTRIES / sizeof(char *))
struct exec_package;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: proc.h,v 1.362 2024/07/08 13:17:12 claudio Exp $ */
/* $OpenBSD: proc.h,v 1.363 2024/07/15 07:24:03 jsg Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@ -308,8 +308,8 @@ struct process {
"\013WAITED" "\014COREDUMP" "\015SINGLEEXIT" "\016SINGLEUNWIND" \
"\017NOZOMBIE" "\020STOPPED" "\021SYSTEM" "\022EMBRYO" "\023ZOMBIE" \
"\024NOBROADCASTKILL" "\025PLEDGE" "\026WXNEEDED" "\027EXECPLEDGE" \
"\030ORPHAN" "\031CHROOT" "\032NOBTCFI" "\033ITIMER")
"\030ORPHAN" "\031CHROOT" "\032NOBTCFI" "\033ITIMER" "\034PIN" \
"\035LIBCPIN")
struct kcov_dev;
struct lock_list_entry;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ext2fs.h,v 1.26 2021/03/11 13:31:35 jsg Exp $ */
/* $OpenBSD: ext2fs.h,v 1.27 2024/07/15 13:27:36 martijn Exp $ */
/* $NetBSD: ext2fs.h,v 1.10 2000/01/28 16:00:23 bouyer Exp $ */
/*
@ -156,7 +156,48 @@ struct ext2fs {
u_int32_t e2fs_first_meta_bg;
u_int32_t e2fs_mkfs_time;
u_int32_t e2fs_journal_backup[17];
u_int32_t reserved2[172];
u_int32_t e2fs_bcount_hi; /* high bits of blocks count */
u_int32_t e2fs_rbcount_hi; /* high bits of reserved blocks count */
u_int32_t e2fs_fbcount_hi; /* high bits of free blocks count */
u_int16_t e2fs_min_extra_isize; /* all inodes have some bytes */
u_int16_t e2fs_want_extra_isize;/* inodes must reserve some bytes */
u_int32_t e2fs_flags; /* miscellaneous flags */
u_int16_t e2fs_raid_stride; /* RAID stride */
u_int16_t e2fs_mmpintv; /* seconds to wait in MMP checking */
u_int64_t e2fs_mmpblk; /* block for multi-mount protection */
u_int32_t e2fs_raid_stripe_wid; /* blocks on data disks (N * stride) */
u_int8_t e2fs_log_gpf; /* FLEX_BG group size */
u_int8_t e2fs_chksum_type; /* metadata checksum algorithm used */
u_int8_t e2fs_encrypt; /* versioning level for encryption */
u_int8_t e2fs_reserved_pad;
u_int64_t e2fs_kbytes_written; /* number of lifetime kilobytes */
u_int32_t e2fs_snapinum; /* inode number of active snapshot */
u_int32_t e2fs_snapid; /* sequential ID of active snapshot */
u_int64_t e2fs_snaprbcount; /* rsvd blocks for active snapshot */
u_int32_t e2fs_snaplist; /* inode number for on-disk snapshot */
u_int32_t e2fs_errcount; /* number of file system errors */
u_int32_t e2fs_first_errtime; /* first time an error happened */
u_int32_t e2fs_first_errino; /* inode involved in first error */
u_int64_t e2fs_first_errblk; /* block involved of first error */
u_int8_t e2fs_first_errfunc[32];/* function where error happened */
u_int32_t e2fs_first_errline; /* line number where error happened */
u_int32_t e2fs_last_errtime; /* most recent time of an error */
u_int32_t e2fs_last_errino; /* inode involved in last error */
u_int32_t e2fs_last_errline; /* line number where error happened */
u_int64_t e2fs_last_errblk; /* block involved of last error */
u_int8_t e2fs_last_errfunc[32];/* function where error happened */
u_int8_t e2fs_mount_opts[64];
u_int32_t e2fs_usrquota_inum; /* inode for tracking user quota */
u_int32_t e2fs_grpquota_inum; /* inode for tracking group quota */
u_int32_t e2fs_overhead_clusters;/* overhead blocks/clusters */
u_int32_t e2fs_backup_bgs[2]; /* groups with sparse_super2 SBs */
u_int8_t e2fs_encrypt_algos[4];/* encryption algorithms in use */
u_int8_t e2fs_encrypt_pw_salt[16];/* salt used for string2key */
u_int32_t e2fs_lpf_ino; /* location of the lost+found inode */
u_int32_t e2fs_proj_quota_inum; /* inode for tracking project quota */
u_int32_t e2fs_chksum_seed; /* checksum seed */
u_int32_t e2fs_reserved[98]; /* padding to the end of the block */
u_int32_t e2fs_sbchksum; /* superblock checksum */
};