sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-30 02:20:47 +00:00
parent 6fc9e02a30
commit 7768d1f254
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
35 changed files with 335 additions and 351 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_machdep.c,v 1.24 2024/04/13 21:57:22 dv Exp $ */
/* $OpenBSD: vmm_machdep.c,v 1.25 2024/04/29 14:47:05 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -3691,18 +3691,14 @@ vm_run(struct vm_run_params *vrp)
}
/*
* We may be returning from userland helping us from the last exit.
* If so (vrp_continue == 1), copy in the exit data from vmd. The
* exit data will be consumed before the next entry (this typically
* comprises VCPU register changes as the result of vmd(8)'s actions).
* We may be returning from userland helping us from the last
* exit. Copy in the exit data from vmd. The exit data will be
* consumed before the next entry (this typically comprises
* VCPU register changes as the result of vmd(8)'s actions).
*/
if (vrp->vrp_continue) {
if (copyin(vrp->vrp_exit, &vcpu->vc_exit,
sizeof(struct vm_exit)) == EFAULT) {
ret = EFAULT;
goto out_unlock;
}
}
ret = copyin(vrp->vrp_exit, &vcpu->vc_exit, sizeof(struct vm_exit));
if (ret)
goto out_unlock;
vcpu->vc_inject.vie_type = vrp->vrp_inject.vie_type;
vcpu->vc_inject.vie_vector = vrp->vrp_inject.vie_vector;
@ -4001,67 +3997,28 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
else
vcpu->vc_intr = 0;
if (vrp->vrp_continue) {
switch (vcpu->vc_gueststate.vg_exit_reason) {
case VMX_EXIT_IO:
if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN)
vcpu->vc_gueststate.vg_rax =
vcpu->vc_exit.vei.vei_data;
vcpu->vc_gueststate.vg_rip =
vcpu->vc_exit.vrs.vrs_gprs[VCPU_REGS_RIP];
if (vmwrite(VMCS_GUEST_IA32_RIP,
vcpu->vc_gueststate.vg_rip)) {
printf("%s: failed to update rip\n", __func__);
return (EINVAL);
}
break;
case VMX_EXIT_EPT_VIOLATION:
ret = vcpu_writeregs_vmx(vcpu, VM_RWREGS_GPRS, 0,
&vcpu->vc_exit.vrs);
if (ret) {
printf("%s: vm %d vcpu %d failed to update "
"registers\n", __func__,
vcpu->vc_parent->vm_id, vcpu->vc_id);
return (EINVAL);
}
break;
case VM_EXIT_NONE:
case VMX_EXIT_HLT:
case VMX_EXIT_INT_WINDOW:
case VMX_EXIT_EXTINT:
case VMX_EXIT_CPUID:
case VMX_EXIT_XSETBV:
break;
#ifdef VMM_DEBUG
case VMX_EXIT_TRIPLE_FAULT:
DPRINTF("%s: vm %d vcpu %d triple fault\n",
__func__, vcpu->vc_parent->vm_id,
vcpu->vc_id);
vmx_vcpu_dump_regs(vcpu);
dump_vcpu(vcpu);
vmx_dump_vmcs(vcpu);
break;
case VMX_EXIT_ENTRY_FAILED_GUEST_STATE:
DPRINTF("%s: vm %d vcpu %d failed entry "
"due to invalid guest state\n",
__func__, vcpu->vc_parent->vm_id,
vcpu->vc_id);
vmx_vcpu_dump_regs(vcpu);
dump_vcpu(vcpu);
switch (vcpu->vc_gueststate.vg_exit_reason) {
case VMX_EXIT_IO:
if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN)
vcpu->vc_gueststate.vg_rax = vcpu->vc_exit.vei.vei_data;
vcpu->vc_gueststate.vg_rip =
vcpu->vc_exit.vrs.vrs_gprs[VCPU_REGS_RIP];
if (vmwrite(VMCS_GUEST_IA32_RIP, vcpu->vc_gueststate.vg_rip)) {
printf("%s: failed to update rip\n", __func__);
return (EINVAL);
default:
DPRINTF("%s: unimplemented exit type %d (%s)\n",
__func__,
vcpu->vc_gueststate.vg_exit_reason,
vmx_exit_reason_decode(
vcpu->vc_gueststate.vg_exit_reason));
vmx_vcpu_dump_regs(vcpu);
dump_vcpu(vcpu);
break;
#endif /* VMM_DEBUG */
}
memset(&vcpu->vc_exit, 0, sizeof(vcpu->vc_exit));
break;
case VMX_EXIT_EPT_VIOLATION:
ret = vcpu_writeregs_vmx(vcpu, VM_RWREGS_GPRS, 0,
&vcpu->vc_exit.vrs);
if (ret) {
printf("%s: vm %d vcpu %d failed to update registers\n",
__func__, vcpu->vc_parent->vm_id, vcpu->vc_id);
return (EINVAL);
}
break;
}
memset(&vcpu->vc_exit, 0, sizeof(vcpu->vc_exit));
/* Host CR3 */
cr3 = rcr3();
@ -6519,31 +6476,29 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
* needs to be fixed up depends on what vmd populated in the
* exit data structure.
*/
if (vrp->vrp_continue) {
switch (vcpu->vc_gueststate.vg_exit_reason) {
case SVM_VMEXIT_IOIO:
if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN) {
vcpu->vc_gueststate.vg_rax =
vcpu->vc_exit.vei.vei_data;
vmcb->v_rax = vcpu->vc_gueststate.vg_rax;
}
vcpu->vc_gueststate.vg_rip =
vcpu->vc_exit.vrs.vrs_gprs[VCPU_REGS_RIP];
vmcb->v_rip = vcpu->vc_gueststate.vg_rip;
break;
case SVM_VMEXIT_NPF:
ret = vcpu_writeregs_svm(vcpu, VM_RWREGS_GPRS,
&vcpu->vc_exit.vrs);
if (ret) {
printf("%s: vm %d vcpu %d failed to update "
"registers\n", __func__,
vcpu->vc_parent->vm_id, vcpu->vc_id);
return (EINVAL);
}
break;
switch (vcpu->vc_gueststate.vg_exit_reason) {
case SVM_VMEXIT_IOIO:
if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN) {
vcpu->vc_gueststate.vg_rax =
vcpu->vc_exit.vei.vei_data;
vmcb->v_rax = vcpu->vc_gueststate.vg_rax;
}
memset(&vcpu->vc_exit, 0, sizeof(vcpu->vc_exit));
vcpu->vc_gueststate.vg_rip =
vcpu->vc_exit.vrs.vrs_gprs[VCPU_REGS_RIP];
vmcb->v_rip = vcpu->vc_gueststate.vg_rip;
break;
case SVM_VMEXIT_NPF:
ret = vcpu_writeregs_svm(vcpu, VM_RWREGS_GPRS,
&vcpu->vc_exit.vrs);
if (ret) {
printf("%s: vm %d vcpu %d failed to update "
"registers\n", __func__,
vcpu->vc_parent->vm_id, vcpu->vc_id);
return (EINVAL);
}
break;
}
memset(&vcpu->vc_exit, 0, sizeof(vcpu->vc_exit));
while (ret == 0) {
vmm_update_pvclock(vcpu);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmmvar.h,v 1.100 2024/04/09 21:55:16 dv Exp $ */
/* $OpenBSD: vmmvar.h,v 1.101 2024/04/29 14:47:05 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -478,7 +478,6 @@ struct vm_run_params {
/* Input parameters to VMM_IOC_RUN */
uint32_t vrp_vm_id;
uint32_t vrp_vcpu_id;
uint8_t vrp_continue; /* Continuing from an exit */
struct vcpu_inject_event vrp_inject;
uint8_t vrp_intr_pending; /* Additional intrs pending? */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fault.c,v 1.47 2023/01/05 20:35:44 kettenis Exp $ */
/* $OpenBSD: fault.c,v 1.48 2024/04/29 12:33:17 jsg Exp $ */
/* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */
/*
@ -96,10 +96,6 @@
#include <arm/machdep.h>
#include <arm/vfp.h>
#ifdef DEBUG
int last_fault_code; /* For the benefit of pmap_fault_fixup() */
#endif
struct sigdata {
int signo;
int code;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.h,v 1.5 2016/09/24 13:43:25 kettenis Exp $ */
/* $OpenBSD: machdep.h,v 1.6 2024/04/29 12:24:46 jsg Exp $ */
/* $NetBSD: machdep.h,v 1.7 2002/02/21 02:52:21 thorpej Exp $ */
#ifndef _ARM_MACHDEP_H_
@ -6,7 +6,6 @@
/* misc prototypes used by the many arm machdeps */
void halt (void);
void parse_mi_bootargs (char *);
void data_abort_handler (trapframe_t *);
void prefetch_abort_handler (trapframe_t *);
void undefinedinstruction_bounce (trapframe_t *);
@ -18,10 +17,4 @@ void dumpsys (void);
*/
u_int initarm (void *, void *, void *, paddr_t);
/* from arm/arm/intr.c */
void dosoftints (void);
void set_spl_masks (void);
#ifdef DIAGNOSTIC
void dump_spl_masks (void);
#endif
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pmap.h,v 1.55 2023/12/11 22:12:53 kettenis Exp $ */
/* $OpenBSD: pmap.h,v 1.56 2024/04/29 12:24:46 jsg Exp $ */
/* $NetBSD: pmap.h,v 1.76 2003/09/06 09:10:46 rearnsha Exp $ */
/*
@ -153,18 +153,6 @@ union pmap_cache_state {
*/
#define PMAP_CACHE_STATE_ALL 0xffffffffu
/*
* This structure is used by machine-dependent code to describe
* static mappings of devices, created at bootstrap time.
*/
struct pmap_devmap {
vaddr_t pd_va; /* virtual address */
paddr_t pd_pa; /* physical address */
psize_t pd_size; /* size of region */
vm_prot_t pd_prot; /* protection code */
int pd_cache; /* cache attributes */
};
/*
* The pmap structure itself
*/
@ -245,12 +233,6 @@ extern struct pmap kernel_pmap_store;
#define pmap_unuse_final(p) do { /* nothing */ } while (0)
#define pmap_remove_holes(vm) do { /* nothing */ } while (0)
/*
* Functions that we need to export
*/
void pmap_remove_all(pmap_t);
void pmap_uncache_page(paddr_t, vaddr_t);
#define PMAP_CHECK_COPYIN 1
#define PMAP_GROWKERNEL /* turn on pmap_growkernel interface */
@ -258,7 +240,6 @@ void pmap_uncache_page(paddr_t, vaddr_t);
/* Functions we use internally. */
void pmap_bootstrap(pd_entry_t *, vaddr_t, vaddr_t);
int pmap_fault_fixup(pmap_t, vaddr_t, vm_prot_t, int);
int pmap_get_pde_pte(pmap_t, vaddr_t, pd_entry_t **, pt_entry_t **);
int pmap_get_pde(pmap_t, vaddr_t, pd_entry_t **);
void pmap_set_pcb_pagedir(pmap_t, struct pcb *);
@ -270,16 +251,11 @@ void vector_page_setprot(int);
/* XXX */
void pmap_kenter_cache(vaddr_t va, paddr_t pa, vm_prot_t prot, int cacheable);
const struct pmap_devmap *pmap_devmap_find_pa(paddr_t, psize_t);
const struct pmap_devmap *pmap_devmap_find_va(vaddr_t, vsize_t);
/* Bootstrapping routines. */
void pmap_map_section(vaddr_t, vaddr_t, paddr_t, int, int);
void pmap_map_entry(vaddr_t, vaddr_t, paddr_t, int, int);
vsize_t pmap_map_chunk(vaddr_t, vaddr_t, paddr_t, vsize_t, int, int);
void pmap_link_l2pt(vaddr_t, vaddr_t, pv_addr_t *);
void pmap_devmap_bootstrap(vaddr_t, const struct pmap_devmap *);
void pmap_devmap_register(const struct pmap_devmap *);
/*
* The current top of kernel VM

View file

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.88 2024/03/17 13:05:40 kettenis Exp $ */
/* $OpenBSD: machdep.c,v 1.89 2024/04/29 13:01:54 jsg Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
@ -620,11 +620,6 @@ dumpsys(void)
int (*dump)(dev_t, daddr_t, caddr_t, size_t);
int error;
#if 0
/* Save registers. */
savectx(&dumppcb);
#endif
if (dumpdev == NODEV)
return;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.h,v 1.45 2024/04/19 10:22:50 mpi Exp $ */
/* $OpenBSD: cpu.h,v 1.46 2024/04/29 13:01:54 jsg Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
*
@ -96,10 +96,6 @@ extern uint64_t cpu_id_aa64pfr1;
#define PROC_PC(p) ((p)->p_addr->u_pcb.pcb_tf->tf_elr)
#define PROC_STACK(p) ((p)->p_addr->u_pcb.pcb_tf->tf_sp)
/* The address of the vector page. */
extern vaddr_t vector_page;
void arm32_vector_init(vaddr_t, int);
/*
* Per-CPU information. For now we assume one CPU.
*/
@ -276,29 +272,15 @@ void need_resched(struct cpu_info *);
// asm code to start new kernel contexts.
void proc_trampoline(void);
void child_trampoline(void);
/*
* Random cruft
*/
void dumpconf(void);
// cpuswitch.S
struct pcb;
void savectx (struct pcb *pcb);
// machdep.h
void bootsync (int);
// fault.c
int badaddr_read (void *, size_t, void *);
// syscall.c
void svc_handler (trapframe_t *);
/* machine_machdep.c */
void board_startup(void);
// functions to manipulate interrupt state
static __inline void
restore_daif(uint32_t daif)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: intc.c,v 1.12 2022/01/03 03:06:50 jsg Exp $ */
/* $OpenBSD: intc.c,v 1.14 2024/04/29 12:42:06 jsg Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@ -91,8 +91,6 @@ struct intrq {
int iq_ist; /* share type */
};
volatile int softint_pending;
struct intrq intc_handler[INTC_MAX_IRQ];
u_int32_t intc_smask[NIPL];
u_int32_t intc_imask[INTC_MAX_BANKS][NIPL];
@ -310,18 +308,6 @@ intc_setipl(int new)
restore_interrupts(psw);
}
void
intc_intr_bootstrap(vaddr_t addr)
{
int i, j;
extern struct bus_space armv7_bs_tag;
intc_iot = &armv7_bs_tag;
intc_ioh = addr;
for (i = 0; i < INTC_NUM_BANKS; i++)
for (j = 0; j < NIPL; j++)
intc_imask[i][j] = 0xffffffff;
}
void
intc_irq_handler(void *frame)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: intc.h,v 1.4 2020/07/14 15:34:15 patrick Exp $ */
/* $OpenBSD: intc.h,v 1.8 2024/04/29 12:46:22 jsg Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@ -25,42 +25,11 @@
#include <machine/intr.h>
#include <arm/softintr.h>
extern volatile int current_spl_level;
extern volatile int softint_pending;
void intc_do_pending(void);
#define SI_TO_IRQBIT(si) (1U<<(si))
void intc_setipl(int new);
void intc_splx(int new);
int intc_splraise(int ipl);
int intc_spllower(int ipl);
void intc_setsoftintr(int si);
/*
* An useful function for interrupt handlers.
* XXX: This shouldn't be here.
*/
static __inline int
find_first_bit( uint32_t bits )
{
int count;
/* since CLZ is available only on ARMv5, this isn't portable
* to all ARM CPUs. This file is for OMAPINTC processor.
*/
asm( "clz %0, %1" : "=r" (count) : "r" (bits) );
return 31-count;
}
/*
* This function *MUST* be called very early on in a port's
* initarm() function, before ANY spl*() functions are called.
*
* The parameter is the virtual address of the OMAPINTC's Interrupt
* Controller registers.
*/
void intc_intr_bootstrap(vaddr_t);
void intc_irq_handler(void *);
void *intc_intr_establish(int irqno, int level, struct cpu_info *ci,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sxiintc.c,v 1.11 2022/01/03 03:06:50 jsg Exp $ */
/* $OpenBSD: sxiintc.c,v 1.12 2024/04/29 12:33:17 jsg Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2013 Artturi Alm
@ -131,8 +131,6 @@ struct intrq {
int iq_ist; /* share type */
};
volatile int a1xsoftint_pending;
struct intrq sxiintc_handler[NIRQ];
u_int32_t sxiintc_smask[NIPL];
u_int32_t sxiintc_imask[NBANKS][NIPL];

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sxiintc.h,v 1.2 2020/07/14 15:34:15 patrick Exp $ */
/* $OpenBSD: sxiintc.h,v 1.4 2024/04/29 12:33:17 jsg Exp $ */
/*
* Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
*
@ -25,16 +25,11 @@
#include <machine/intr.h>
#include <arm/softintr.h>
extern volatile int current_spl_level;
extern volatile int softint_pending;
void sxiintc_do_pending(void);
#define SI_TO_IRQBIT(si) (1U<<(si))
void sxiintc_setipl(int);
void sxiintc_splx(int);
int sxiintc_splraise(int);
int sxiintc_spllower(int);
void sxiintc_setsoftintr(int);
void sxiintc_irq_handler(void *);
void *sxiintc_intr_establish(int, int, struct cpu_info *,