sync with OpenBSD -current

This commit is contained in:
purplerain 2024-07-11 15:49:23 +00:00
parent a8049e67d3
commit ae019f102d
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
77 changed files with 4413 additions and 6362 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: locore0.S,v 1.23 2024/05/12 16:49:38 guenther Exp $ */
/* $OpenBSD: locore0.S,v 1.24 2024/07/10 12:36:13 bluhm Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@ -314,17 +314,21 @@ cont:
NDML3_ENTRIES + NDML2_ENTRIES + 3) * NBPG)
#define fillkpt \
1: movl %eax,(%ebx) ; /* store phys addr */ \
movl $0,4(%ebx) ; /* upper 32 bits 0 */ \
addl $8,%ebx ; /* next pte/pde */ \
addl $NBPG,%eax ; /* next phys page */ \
loop 1b ; /* till finished */
pushl %ebp ; /* save */ \
movl RELOC((pg_crypt + 4)), %ebp ; /* C bit? */ \
1: movl %eax,(%ebx) ; /* store phys addr */ \
movl %ebp,4(%ebx) ; /* upper 32 bits */ \
addl $8,%ebx ; /* next pte/pde */ \
addl $NBPG,%eax ; /* next phys page */ \
loop 1b ; /* till finished */ \
popl %ebp ; /* restore */
#define fillkpt_nx \
pushl %ebp ; /* save */ \
1: movl %eax,(%ebx) ; /* store phys addr */ \
movl RELOC((pg_nx + 4)), %ebp ; /* NX bit? */ \
orl RELOC((pg_crypt + 4)), %ebp ; /* C bit? */ \
1: movl %eax,(%ebx) ; /* store phys addr */ \
movl %ebp,4(%ebx) ; /* upper 32 bits */ \
addl $8,%ebx ; /* next pte/pde */ \
addl $NBPG,%eax ; /* next phys page */ \
@ -510,6 +514,7 @@ store_pte:
movl %eax, (%ebx)
pushl %ebp
movl RELOC((pg_nx + 4)), %ebp
orl RELOC((pg_crypt + 4)), %ebp
movl %ebp, 4(%ebx)
popl %ebp
addl $8, %ebx
@ -535,6 +540,7 @@ store_pte:
movl %eax,(%ebx)
pushl %ebp
movl RELOC((pg_nx + 4)), %ebp
orl RELOC((pg_crypt + 4)), %ebp
movl %ebp, 4(%ebx)
popl %ebp

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmmvar.h,v 1.102 2024/07/09 09:31:37 dv Exp $ */
/* $OpenBSD: vmmvar.h,v 1.103 2024/07/10 09:27:32 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -88,15 +88,15 @@
#define VMX_EXIT_XSAVES 63
#define VMX_EXIT_XRSTORS 64
#define VM_EXIT_TERMINATED 0xFFFE
#define VM_EXIT_NONE 0xFFFF
/*
* VMX: Misc defines
*/
#define VMX_MAX_CR3_TARGETS 256
#define VMX_VMCS_PA_CLEAR 0xFFFFFFFFFFFFFFFFUL
#define VM_EXIT_TERMINATED 0xFFFE
#define VM_EXIT_NONE 0xFFFF
/*
* SVM: Intercept codes (exit reasons)
*/
@ -473,20 +473,6 @@ struct vm_intr_params {
uint16_t vip_intr;
};
#define VM_RWVMPARAMS_PVCLOCK_SYSTEM_GPA 0x1 /* read/write pvclock gpa */
#define VM_RWVMPARAMS_PVCLOCK_VERSION 0x2 /* read/write pvclock version */
#define VM_RWVMPARAMS_ALL (VM_RWVMPARAMS_PVCLOCK_SYSTEM_GPA | \
VM_RWVMPARAMS_PVCLOCK_VERSION)
struct vm_rwvmparams_params {
/* Input parameters to VMM_IOC_READVMPARAMS/VMM_IOC_WRITEVMPARAMS */
uint32_t vpp_vm_id;
uint32_t vpp_vcpu_id;
uint32_t vpp_mask;
paddr_t vpp_pvclock_system_gpa;
uint32_t vpp_pvclock_version;
};
#define VM_RWREGS_GPRS 0x1 /* read/write GPRs */
#define VM_RWREGS_SREGS 0x2 /* read/write segment registers */
#define VM_RWREGS_CRS 0x4 /* read/write CRs */
@ -936,7 +922,6 @@ int vm_impl_init(struct vm *, struct proc *);
void vm_impl_deinit(struct vm *);
int vcpu_init(struct vcpu *);
void vcpu_deinit(struct vcpu *);
int vm_rwvmparams(struct vm_rwvmparams_params *, int);
int vm_rwregs(struct vm_rwregs_params *, int);
int vcpu_reset_regs(struct vcpu *, struct vcpu_reg_state *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.c,v 1.123 2024/07/02 19:59:54 kettenis Exp $ */
/* $OpenBSD: cpu.c,v 1.125 2024/07/11 12:07:39 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
@ -245,6 +245,7 @@ uint64_t cpu_id_aa64pfr0;
uint64_t cpu_id_aa64pfr1;
int arm64_has_lse;
int arm64_has_rng;
#ifdef CRYPTO
int arm64_has_aes;
#endif
@ -273,8 +274,12 @@ struct cfdriver cpu_cd = {
NULL, "cpu", DV_DULL
};
struct timeout cpu_rng_to;
void cpu_rng(void *);
void cpu_opp_init(struct cpu_info *, uint32_t);
void cpu_psci_init(struct cpu_info *);
void cpu_psci_idle_cycle(void);
void cpu_flush_bp_noop(void);
void cpu_flush_bp_psci(void);
@ -285,6 +290,25 @@ void cpu_kstat_attach(struct cpu_info *ci);
void cpu_opp_kstat_attach(struct cpu_info *ci);
#endif
void
cpu_rng(void *arg)
{
struct timeout *to = arg;
uint64_t rndr;
int ret;
ret = __builtin_arm_rndrrs(&rndr);
if (ret)
ret = __builtin_arm_rndr(&rndr);
if (ret == 0) {
enqueue_randomness(rndr & 0xffffffff);
enqueue_randomness(rndr >> 32);
}
if (to)
timeout_add_msec(to, 1000);
}
/*
* Enable mitigation for Spectre-V2 branch target injection
* vulnerabilities (CVE-2017-5715).
@ -666,6 +690,7 @@ cpu_identify(struct cpu_info *ci)
if (ID_AA64ISAR0_RNDR(id) >= ID_AA64ISAR0_RNDR_IMPL) {
printf("%sRNDR", sep);
sep = ",";
arm64_has_rng = 1;
}
if (ID_AA64ISAR0_TLB(id) >= ID_AA64ISAR0_TLB_IOS) {
@ -1138,6 +1163,11 @@ cpu_attach(struct device *parent, struct device *dev, void *aux)
}
cpu_init();
if (arm64_has_rng) {
timeout_set(&cpu_rng_to, cpu_rng, &cpu_rng_to);
cpu_rng(&cpu_rng_to);
}
#ifdef MULTIPROCESSOR
}
#endif
@ -1955,6 +1985,51 @@ cpu_psci_init(struct cpu_info *ci)
uint32_t cluster;
int idx, len, node;
/*
* Find the shallowest (for now) idle state for this CPU.
* This should be the first one that is listed. We'll use it
* in the idle loop.
*/
len = OF_getproplen(ci->ci_node, "cpu-idle-states");
if (len < (int)sizeof(uint32_t))
return;
states = malloc(len, M_TEMP, M_WAITOK);
OF_getpropintarray(ci->ci_node, "cpu-idle-states", states, len);
node = OF_getnodebyphandle(states[0]);
free(states, M_TEMP, len);
if (node) {
uint32_t entry, exit, residency, param;
int32_t features;
param = OF_getpropint(node, "arm,psci-suspend-param", 0);
entry = OF_getpropint(node, "entry-latency-us", 0);
exit = OF_getpropint(node, "exit-latency-us", 0);
residency = OF_getpropint(node, "min-residency-us", 0);
ci->ci_psci_idle_latency += entry + exit + 2 * residency;
/* Skip states that stop the local timer. */
if (OF_getpropbool(node, "local-timer-stop"))
ci->ci_psci_idle_param = 0;
/* Skip powerdown states. */
features = psci_features(CPU_SUSPEND);
if (features == PSCI_NOT_SUPPORTED ||
(features & PSCI_FEATURE_POWER_STATE_EXT) == 0) {
if (param & PSCI_POWER_STATE_POWERDOWN)
param = 0;
} else {
if (param & PSCI_POWER_STATE_EXT_POWERDOWN)
param = 0;
}
if (param) {
ci->ci_psci_idle_param = param;
cpu_idle_cycle_fcn = cpu_psci_idle_cycle;
}
}
/*
* Hunt for the deepest idle state for this CPU. This is
* fairly complicated as it requires traversing quite a few
@ -2052,6 +2127,30 @@ cpu_psci_init(struct cpu_info *ci)
OF_getpropint(node, "arm,psci-suspend-param", 0);
}
void
cpu_psci_idle_cycle(void)
{
struct cpu_info *ci = curcpu();
struct timeval start, stop;
u_long itime;
microuptime(&start);
if (ci->ci_prev_sleep > ci->ci_psci_idle_latency)
psci_cpu_suspend(ci->ci_psci_idle_param, 0, 0);
else
cpu_wfi();
microuptime(&stop);
timersub(&stop, &start, &stop);
itime = stop.tv_sec * 1000000 + stop.tv_usec;
ci->ci_last_itime = itime;
itime >>= 1;
ci->ci_prev_sleep = (ci->ci_prev_sleep + (ci->ci_prev_sleep >> 1)
+ itime) >> 1;
}
#if NKSTAT > 0
struct cpu_kstats {

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.arm64,v 1.48 2024/07/02 10:25:16 kettenis Exp $
# $OpenBSD: Makefile.arm64,v 1.49 2024/07/11 12:07:40 kettenis Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
@ -56,7 +56,7 @@ CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \
-Wno-unused-but-set-variable -Wno-gnu-folding-constant \
-Wframe-larger-than=2047
CMACHFLAGS= -march=armv8-a+nofp+nosimd \
CMACHFLAGS= -march=armv8-a+nofp+nosimd+rng \
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
-ffixed-x18
CMACHFLAGS+= -ffreestanding ${NOPIE_FLAGS}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.h,v 1.47 2024/05/01 12:54:27 mpi Exp $ */
/* $OpenBSD: cpu.h,v 1.48 2024/07/10 11:01:24 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
@ -146,6 +146,8 @@ struct cpu_info {
uint64_t ci_ttbr1;
vaddr_t ci_el1_stkend;
uint32_t ci_psci_idle_latency;
uint32_t ci_psci_idle_param;
uint32_t ci_psci_suspend_param;
struct opp_table *ci_opp_table;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: efivar.h,v 1.1 2023/01/14 12:11:11 kettenis Exp $ */
/* $OpenBSD: efivar.h,v 1.2 2024/07/10 10:53:55 kettenis Exp $ */
/*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
*
@ -30,6 +30,11 @@ struct efi_softc {
struct todr_chip_handle sc_todr;
};
extern EFI_GET_VARIABLE efi_get_variable;
extern EFI_SET_VARIABLE efi_set_variable;
extern EFI_GET_NEXT_VARIABLE_NAME efi_get_next_variable_name;
void efi_enter(struct efi_softc *);
void efi_leave(struct efi_softc *);

View file

@ -0,0 +1,91 @@
/* $OpenBSD: vmmvar.h,v 1.1 2024/07/10 10:41:19 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* CPU capabilities for VMM operation
*/
#ifndef _MACHINE_VMMVAR_H_
#define _MACHINE_VMMVAR_H_
#define VMM_HV_SIGNATURE "OpenBSDVMM58"
#define VMM_PCI_MMIO_BAR_BASE 0xF0000000ULL
#define VMM_PCI_MMIO_BAR_END 0xFFDFFFFFULL /* 2 MiB below 4 GiB */
/* Exit Reasons */
#define VM_EXIT_TERMINATED 0xFFFE
#define VM_EXIT_NONE 0xFFFF
struct vmm_softc_md {
/* Capabilities */
uint32_t nr_cpus; /* [I] */
};
/*
* struct vcpu_inject_event : describes an exception or interrupt to inject.
*/
struct vcpu_inject_event {
uint8_t vie_vector; /* Exception or interrupt vector. */
uint32_t vie_errorcode; /* Optional error code. */
uint8_t vie_type;
#define VCPU_INJECT_NONE 0
#define VCPU_INJECT_INTR 1 /* External hardware interrupt. */
#define VCPU_INJECT_EX 2 /* HW or SW Exception */
#define VCPU_INJECT_NMI 3 /* Non-maskable Interrupt */
};
#define VCPU_REGS_NGPRS 31
struct vcpu_reg_state {
uint64_t vrs_gprs[VCPU_REGS_NGPRS];
};
/*
* struct vm_exit
*
* Contains VM exit information communicated to vmd(8). This information is
* gathered by vmm(4) from the CPU on each exit that requires help from vmd.
*/
struct vm_exit {
struct vcpu_reg_state vrs;
};
struct vm_intr_params {
/* Input parameters to VMM_IOC_INTR */
uint32_t vip_vm_id;
uint32_t vip_vcpu_id;
uint16_t vip_intr;
};
#define VM_RWREGS_GPRS 0x1 /* read/write GPRs */
#define VM_RWREGS_ALL (VM_RWREGS_GPRS)
struct vm_rwregs_params {
/*
* Input/output parameters to VMM_IOC_READREGS /
* VMM_IOC_WRITEREGS
*/
uint32_t vrwp_vm_id;
uint32_t vrwp_vcpu_id;
uint64_t vrwp_mask;
struct vcpu_reg_state vrwp_regs;
};
/* IOCTL definitions */
#define VMM_IOC_INTR _IOW('V', 6, struct vm_intr_params) /* Intr pending */
#endif /* ! _MACHINE_VMMVAR_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: efiboot.c,v 1.56 2024/07/07 09:38:44 patrick Exp $ */
/* $OpenBSD: efiboot.c,v 1.57 2024/07/10 18:46:42 patrick Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@ -588,7 +588,8 @@ efi_dma_constraint(void)
fdt_node_is_compatible(node, "rockchip,rk3588") ||
fdt_node_is_compatible(node, "rockchip,rk3588s"))
dma_constraint[1] = htobe64(0xffffffff);
if (fdt_node_is_compatible(node, "lenovo,thinkpad-x13s"))
if (fdt_node_is_compatible(node, "qcom,sc8280xp") ||
fdt_node_is_compatible(node, "qcom,x1e80100"))
dma_constraint[1] = htobe64(0xffffffff);
/* Pass DMA constraint. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: efi.c,v 1.1 2023/01/14 12:11:11 kettenis Exp $ */
/* $OpenBSD: efi.c,v 1.2 2024/07/10 10:53:55 kettenis Exp $ */
/*
* Copyright (c) 2022 3mdeb <contact@3mdeb.com>
*
@ -33,6 +33,10 @@ int efiioc_var_next(struct efi_softc *sc, void *);
int efiioc_var_set(struct efi_softc *sc, void *);
int efi_adapt_error(EFI_STATUS);
EFI_GET_VARIABLE efi_get_variable;
EFI_SET_VARIABLE efi_set_variable;
EFI_GET_NEXT_VARIABLE_NAME efi_get_next_variable_name;
int
efiopen(dev_t dev, int flag, int mode, struct proc *p)
{
@ -142,13 +146,18 @@ efiioc_var_get(struct efi_softc *sc, void *data)
goto leave;
}
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
if (efi_get_variable) {
status = efi_get_variable(name, (EFI_GUID *)&ioc->vendor,
&ioc->attrib, &ioc->datasize, value);
} else {
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
}
status = sc->sc_rs->GetVariable(name, (EFI_GUID *)&ioc->vendor,
&ioc->attrib, &ioc->datasize, value);
efi_leave(sc);
}
status = sc->sc_rs->GetVariable(name, (EFI_GUID *)&ioc->vendor,
&ioc->attrib, &ioc->datasize, value);
efi_leave(sc);
if (status == EFI_BUFFER_TOO_SMALL) {
/*
@ -183,13 +192,18 @@ efiioc_var_next(struct efi_softc *sc, void *data)
if (error)
goto leave;
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
if (efi_get_next_variable_name) {
status = efi_get_next_variable_name(&ioc->namesize,
name, (EFI_GUID *)&ioc->vendor);
} else {
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
}
status = sc->sc_rs->GetNextVariableName(&ioc->namesize,
name, (EFI_GUID *)&ioc->vendor);
efi_leave(sc);
}
status = sc->sc_rs->GetNextVariableName(&ioc->namesize,
name, (EFI_GUID *)&ioc->vendor);
efi_leave(sc);
if (status == EFI_BUFFER_TOO_SMALL) {
/*
@ -242,13 +256,18 @@ efiioc_var_set(struct efi_softc *sc, void *data)
goto leave;
}
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
if (efi_set_variable) {
status = efi_set_variable(name, (EFI_GUID *)&ioc->vendor,
ioc->attrib, ioc->datasize, value);
} else {
if (efi_enter_check(sc)) {
error = ENOSYS;
goto leave;
}
status = sc->sc_rs->SetVariable(name, (EFI_GUID *)&ioc->vendor,
ioc->attrib, ioc->datasize, value);
efi_leave(sc);
}
status = sc->sc_rs->SetVariable(name, (EFI_GUID *)&ioc->vendor,
ioc->attrib, ioc->datasize, value);
efi_leave(sc);
error = efi_adapt_error(status);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: psci.c,v 1.16 2024/04/13 14:20:48 kettenis Exp $ */
/* $OpenBSD: psci.c,v 1.17 2024/07/10 11:01:24 kettenis Exp $ */
/*
* Copyright (c) 2016 Jonathan Gray <jsg@openbsd.org>
@ -37,27 +37,6 @@ extern void (*powerdownfn)(void);
#define SMCCC_ARCH_WORKAROUND_2 0x80007fff
#define SMCCC_ARCH_WORKAROUND_3 0x80003fff
#define PSCI_VERSION 0x84000000
#ifdef __LP64__
#define CPU_SUSPEND 0xc4000001
#else
#define CPU_SUSPEND 0x84000001
#endif
#define CPU_OFF 0x84000002
#ifdef __LP64__
#define CPU_ON 0xc4000003
#else
#define CPU_ON 0x84000003
#endif
#define SYSTEM_OFF 0x84000008
#define SYSTEM_RESET 0x84000009
#define PSCI_FEATURES 0x8400000a
#ifdef __LP64__
#define SYSTEM_SUSPEND 0xc400000e
#else
#define SYSTEM_SUSPEND 0x8400000e
#endif
struct psci_softc {
struct device sc_dev;
register_t (*sc_callfn)(register_t, register_t, register_t,

View file

@ -10,12 +10,38 @@
#define PSCI_METHOD_HVC 1
#define PSCI_METHOD_SMC 2
#define PSCI_VERSION 0x84000000
#ifdef __LP64__
#define CPU_SUSPEND 0xc4000001
#else
#define CPU_SUSPEND 0x84000001
#endif
#define CPU_OFF 0x84000002
#ifdef __LP64__
#define CPU_ON 0xc4000003
#else
#define CPU_ON 0x84000003
#endif
#define SYSTEM_OFF 0x84000008
#define SYSTEM_RESET 0x84000009
#define PSCI_FEATURES 0x8400000a
#ifdef __LP64__
#define SYSTEM_SUSPEND 0xc400000e
#else
#define SYSTEM_SUSPEND 0x8400000e
#endif
#define PSCI_FEATURE_POWER_STATE_EXT (1 << 1)
#define PSCI_POWER_STATE_POWERDOWN (1 << 16)
#define PSCI_POWER_STATE_EXT_POWERDOWN (1 << 30)
int psci_can_suspend(void);
int32_t psci_system_suspend(register_t, register_t);
int32_t psci_cpu_on(register_t, register_t, register_t);
int32_t psci_cpu_off(void);
int32_t psci_cpu_suspend(register_t, register_t, register_t);
int32_t psci_features(uint32_t);
void psci_flush_bp(void);
int psci_method(void);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: qcscm.c,v 1.7 2024/07/04 20:11:46 kettenis Exp $ */
/* $OpenBSD: qcscm.c,v 1.8 2024/07/10 10:53:55 kettenis Exp $ */
/*
* Copyright (c) 2022 Patrick Wildt <patrick@blueri.se>
*
@ -33,11 +33,14 @@
#include <machine/fdt.h>
#include <dev/efi/efi.h>
#include <machine/efivar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_misc.h>
#include <dev/ofw/fdt.h>
#include "efi.h"
/* #define QCSCM_DEBUG */
#define ARM_SMCCC_STD_CALL (0U << 31)
@ -142,6 +145,12 @@ EFI_STATUS qcscm_uefi_set_variable(struct qcscm_softc *, CHAR16 *,
EFI_STATUS qcscm_uefi_get_next_variable(struct qcscm_softc *,
CHAR16 *, int *, EFI_GUID *);
EFI_STATUS qcscm_efi_get_variable(CHAR16 *, EFI_GUID *, UINT32 *,
UINTN *, VOID *);
EFI_STATUS qcscm_efi_set_variable(CHAR16 *, EFI_GUID *, UINT32,
UINTN, VOID *);
EFI_STATUS qcscm_efi_get_next_variable_name(UINTN *, CHAR16 *, EFI_GUID *);
#ifdef QCSCM_DEBUG
void qcscm_uefi_dump_variables(struct qcscm_softc *);
void qcscm_uefi_dump_variable(struct qcscm_softc *, CHAR16 *, int,
@ -188,6 +197,12 @@ qcscm_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
qcscm_sc = sc;
#if NEFI > 0
efi_get_variable = qcscm_efi_get_variable;
efi_set_variable = qcscm_efi_set_variable;
efi_get_next_variable_name = qcscm_efi_get_next_variable_name;
#endif
#ifdef QCSCM_DEBUG
qcscm_uefi_dump_variables(sc);
qcscm_uefi_dump_variable(sc, u"RTCInfo", sizeof(u"RTCInfo"),
@ -418,7 +433,7 @@ qcscm_uefi_get_variable(struct qcscm_softc *sc,
resp = QCSCM_DMA_KVA(qdm) + respoff;
if (resp->command_id != QCTEE_UEFI_GET_VARIABLE ||
resp->length < sizeof(*resp) || resp->length > respsize) {
resp->length < sizeof(*resp)) {
qcscm_dmamem_free(sc, qdm);
return QCTEE_UEFI_DEVICE_ERROR;
}
@ -433,7 +448,8 @@ qcscm_uefi_get_variable(struct qcscm_softc *sc,
return ret;
}
if (resp->data_offset + resp->data_size > resp->length) {
if (resp->length > respsize ||
resp->data_offset + resp->data_size > resp->length) {
qcscm_dmamem_free(sc, qdm);
return QCTEE_UEFI_DEVICE_ERROR;
}
@ -641,7 +657,71 @@ qcscm_uefi_get_next_variable(struct qcscm_softc *sc,
return QCTEE_UEFI_SUCCESS;
}
#if NEFI > 0
EFI_STATUS
qcscm_efi_get_variable(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes,
UINTN *data_size, VOID *data)
{
struct qcscm_softc *sc = qcscm_sc;
EFI_STATUS status;
int name_size;
int size;
name_size = 0;
while (name[name_size])
name_size++;
name_size++;
size = *data_size;
status = qcscm_uefi_get_variable(sc, name, name_size * 2, guid,
attributes, data, &size);
*data_size = size;
/* Convert 32-bit status code to 64-bit. */
return ((status & 0xf0000000) << 32 | (status & 0x0fffffff));
}
EFI_STATUS
qcscm_efi_set_variable(CHAR16 *name, EFI_GUID *guid, UINT32 attributes,
UINTN data_size, VOID *data)
{
struct qcscm_softc *sc = qcscm_sc;
EFI_STATUS status;
int name_size;
name_size = 0;
while (name[name_size])
name_size++;
name_size++;
status = qcscm_uefi_set_variable(sc, name, name_size * 2, guid,
attributes, data, data_size);
/* Convert 32-bit status code to 64-bit. */
return ((status & 0xf0000000) << 32 | (status & 0x0fffffff));
}
EFI_STATUS
qcscm_efi_get_next_variable_name(UINTN *name_size, CHAR16 *name,
EFI_GUID *guid)
{
struct qcscm_softc *sc = qcscm_sc;
EFI_STATUS status;
int size;
size = *name_size;
status = qcscm_uefi_get_next_variable(sc, name, &size, guid);
*name_size = size;
/* Convert 32-bit status code to 64-bit. */
return ((status & 0xf0000000) << 32 | (status & 0x0fffffff));
}
#endif
#ifdef QCSCM_DEBUG
void
qcscm_uefi_dump_variables(struct qcscm_softc *sc)
{
@ -699,6 +779,7 @@ qcscm_uefi_dump_variable(struct qcscm_softc *sc, CHAR16 *name, int namesize,
printf("%02x", data[i]);
printf("\n");
}
#endif
int

View file

@ -60,11 +60,9 @@ struct fb_info {
#define FBINFO_STATE_RUNNING 0
#define FBINFO_STATE_SUSPENDED 1
#define FBINFO_DEFAULT 0
#define FBINFO_VIRTFB 1
#define FBINFO_READS_FAST 2
#define FBINFO_HIDE_SMEM_START 0
#define FBINFO_VIRTFB 0x0001
#define FBINFO_READS_FAST 0x0002
#define FBINFO_HIDE_SMEM_START 0x0004
#define FB_ROTATE_UR 0
#define FB_ROTATE_CW 1

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_iavf.c,v 1.14 2024/07/09 16:04:15 jmatthew Exp $ */
/* $OpenBSD: if_iavf.c,v 1.17 2024/07/10 09:50:28 jmatthew Exp $ */
/*
* Copyright (c) 2013-2015, Intel Corporation
@ -1115,7 +1115,7 @@ iavf_config_hena(struct iavf_softc *sc)
iaq.iaq_flags = htole16(IAVF_AQ_BUF | IAVF_AQ_RD);
iaq.iaq_opcode = htole16(IAVF_AQ_OP_SEND_TO_PF);
iaq.iaq_vc_opcode = htole32(IAVF_VC_OP_SET_RSS_HENA);
iaq.iaq_datalen = htole32(sizeof(*caps));
iaq.iaq_datalen = htole16(sizeof(*caps));
iavf_aq_dva(&iaq, IAVF_DMA_DVA(&sc->sc_scratch));
caps = IAVF_DMA_KVA(&sc->sc_scratch);
@ -2393,11 +2393,15 @@ iavf_atq_done(struct iavf_softc *sc)
unsigned int cons;
unsigned int prod;
mtx_enter(&sc->sc_atq_mtx);
prod = sc->sc_atq_prod;
cons = sc->sc_atq_cons;
if (prod == cons)
if (prod == cons) {
mtx_leave(&sc->sc_atq_mtx);
return;
}
atq = IAVF_DMA_KVA(&sc->sc_atq);
@ -2421,6 +2425,8 @@ iavf_atq_done(struct iavf_softc *sc)
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
sc->sc_atq_cons = cons;
mtx_leave(&sc->sc_atq_mtx);
}
static int
@ -2429,6 +2435,8 @@ iavf_atq_post(struct iavf_softc *sc, struct iavf_aq_desc *iaq)
struct iavf_aq_desc *atq, *slot;
unsigned int prod;
mtx_enter(&sc->sc_atq_mtx);
atq = IAVF_DMA_KVA(&sc->sc_atq);
prod = sc->sc_atq_prod;
slot = atq + prod;
@ -2446,6 +2454,9 @@ iavf_atq_post(struct iavf_softc *sc, struct iavf_aq_desc *iaq)
prod &= IAVF_AQ_MASK;
sc->sc_atq_prod = prod;
iavf_wr(sc, sc->sc_aq_regs->atq_tail, prod);
mtx_leave(&sc->sc_atq_mtx);
return (prod);
}
@ -2554,15 +2565,15 @@ iavf_config_irq_map(struct iavf_softc *sc)
iavf_aq_dva(&iaq, IAVF_DMA_DVA(&sc->sc_scratch));
map = IAVF_DMA_KVA(&sc->sc_scratch);
map->num_vectors = letoh16(1);
map->num_vectors = htole16(1);
vec = map->vecmap;
vec[0].vsi_id = letoh16(sc->sc_vsi_id);
vec[0].vsi_id = htole16(sc->sc_vsi_id);
vec[0].vector_id = 0;
vec[0].rxq_map = letoh16(iavf_allqueues(sc));
vec[0].txq_map = letoh16(iavf_allqueues(sc));
vec[0].rxitr_idx = IAVF_NOITR;
vec[0].txitr_idx = IAVF_NOITR;
vec[0].rxq_map = htole16(iavf_allqueues(sc));
vec[0].txq_map = htole16(iavf_allqueues(sc));
vec[0].rxitr_idx = htole16(IAVF_NOITR);
vec[0].txitr_idx = htole16(IAVF_NOITR);
bus_dmamap_sync(sc->sc_dmat, IAVF_DMA_MAP(&sc->sc_scratch), 0, IAVF_DMA_LEN(&sc->sc_scratch),
BUS_DMASYNC_PREREAD);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm.h,v 1.5 2024/07/09 09:31:37 dv Exp $ */
/* $OpenBSD: vmm.h,v 1.6 2024/07/10 10:41:19 dv Exp $ */
/*
* Copyright (c) 2014-2023 Mike Larkin <mlarkin@openbsd.org>
*
@ -108,6 +108,20 @@ struct vm_run_params {
uint8_t vrp_irqready; /* ready for IRQ on entry */
};
#define VM_RWVMPARAMS_PVCLOCK_SYSTEM_GPA 0x1 /* read/write pvclock gpa */
#define VM_RWVMPARAMS_PVCLOCK_VERSION 0x2 /* read/write pvclock version */
#define VM_RWVMPARAMS_ALL (VM_RWVMPARAMS_PVCLOCK_SYSTEM_GPA | \
VM_RWVMPARAMS_PVCLOCK_VERSION)
struct vm_rwvmparams_params {
/* Input parameters to VMM_IOC_READVMPARAMS/VMM_IOC_WRITEVMPARAMS */
uint32_t vpp_vm_id;
uint32_t vpp_vcpu_id;
uint32_t vpp_mask;
paddr_t vpp_pvclock_system_gpa;
uint32_t vpp_pvclock_version;
};
/* IOCTL definitions */
#define VMM_IOC_CREATE _IOWR('V', 1, struct vm_create_params) /* Create VM */
#define VMM_IOC_RUN _IOWR('V', 2, struct vm_run_params) /* Run VCPU */
@ -225,6 +239,7 @@ void vm_teardown(struct vm **);
int vm_get_info(struct vm_info_params *);
int vm_terminate(struct vm_terminate_params *);
int vm_resetcpu(struct vm_resetcpu_params *);
int vm_rwvmparams(struct vm_rwvmparams_params *, int);
int vcpu_must_stop(struct vcpu *);
int vm_share_mem(struct vm_sharemem_params *, struct proc *);
int vm_run(struct vm_run_params *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sig.c,v 1.331 2024/07/09 09:22:50 claudio Exp $ */
/* $OpenBSD: kern_sig.c,v 1.332 2024/07/10 12:28:46 claudio Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@ -1078,7 +1078,12 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
*/
if (signum == SIGKILL) {
atomic_clearbits_int(&p->p_flag, P_SUSPSIG);
goto runfast;
/* Raise priority to at least PUSER. */
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
unsleep(p);
setrunnable(p);
goto out;
}
if (prop & SA_CONT) {
@ -1097,10 +1102,19 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
wakeparent = 1;
if (action == SIG_DFL)
mask = 0;
if (action == SIG_CATCH)
goto runfast;
if (p->p_wchan == NULL)
goto run;
if (action == SIG_CATCH) {
/* Raise priority to at least PUSER. */
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
unsleep(p);
setrunnable(p);
goto out;
}
if (p->p_wchan == NULL) {
unsleep(p);
setrunnable(p);
goto out;
}
atomic_clearbits_int(&p->p_flag, P_WSLEEP);
p->p_stat = SSLEEP;
goto out;
@ -1146,8 +1160,11 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
* so it can discover the signal in cursig() and stop
* for the parent.
*/
if (pr->ps_flags & PS_TRACED)
goto run;
if (pr->ps_flags & PS_TRACED) {
unsleep(p);
setrunnable(p);
goto out;
}
/*
* Recheck sigmask before waking up the process,
@ -1206,8 +1223,13 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
/*
* All other (caught or default) signals
* cause the process to run.
* Raise priority to at least PUSER.
*/
goto runfast;
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
unsleep(p);
setrunnable(p);
goto out;
/* NOTREACHED */
case SONPROC:
@ -1229,15 +1251,6 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
}
/* NOTREACHED */
runfast:
/*
* Raise priority to at least PUSER.
*/
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
run:
unsleep(p);
setrunnable(p);
out:
/* finally adjust siglist */
if (mask)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sysctl.c,v 1.428 2024/07/08 13:17:12 claudio Exp $ */
/* $OpenBSD: kern_sysctl.c,v 1.429 2024/07/11 14:11:55 bluhm Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/atomic.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/pool.h>
@ -1005,19 +1006,39 @@ int
sysctl_int_bounded(void *oldp, size_t *oldlenp, void *newp, size_t newlen,
int *valp, int minimum, int maximum)
{
int val = *valp;
int oldval, newval;
int error;
/* read only */
if (newp == NULL || minimum > maximum)
return (sysctl_rdint(oldp, oldlenp, newp, val));
if (newp != NULL && minimum > maximum)
return (EPERM);
if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &val)))
return (error);
/* outside limits */
if (val < minimum || maximum < val)
if (oldp != NULL && *oldlenp < sizeof(int))
return (ENOMEM);
if (newp != NULL && newlen != sizeof(int))
return (EINVAL);
*valp = val;
*oldlenp = sizeof(int);
/* copyin() may sleep, call it first */
if (newp != NULL) {
if ((error = copyin(newp, &newval, sizeof(int))))
return (error);
/* outside limits */
if (newval < minimum || maximum < newval)
return (EINVAL);
}
if (oldp != NULL) {
if (newp != NULL)
oldval = atomic_swap_uint(valp, newval);
else
oldval = atomic_load_int(valp);
if ((error = copyout(&oldval, oldp, sizeof(int)))) {
/* new value has been set although user gets error */
return (error);
}
} else if (newp != NULL)
atomic_store_int(valp, newval);
return (0);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vfs_syscalls.c,v 1.365 2024/05/18 05:20:22 guenther Exp $ */
/* $OpenBSD: vfs_syscalls.c,v 1.366 2024/07/10 09:12:11 krw Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@ -697,10 +697,6 @@ sys_getfsstat(struct proc *p, void *v, register_t *retval)
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
#if notyet
if (mp->mnt_flag & MNT_SOFTDEP)
sp->f_eflags = STATFS_SOFTUPD;
#endif
error = (copyout_statfs(sp, sfsp, p));
if (error) {
vfs_unbusy(mp);